Just trying to see what I can do to invent some kind of incremental block based backup solution out of the ground seeing that apparently it does not really exist for Linux.
I mean, it does not exist for me.
I just wrote a shell script that transforms dumpe2fs output into a list of used and unused block ranges:
Code: Select all
$ ./e2zerocat.sh /dev/msata/boot
<snip>
unused: 229825-229952
used: 229953-230208
unused: 230209-230400
used: 230401-230912
unused: 230913-232192
used: 232193-232320
unused: 232321-237568
used: 237569-237826
unused: 237827-238338
used: 238339-239362
unused: 239363-239616
used: 239617-239911
unused: 239912-245759
blocks: 245760
size: 1024
In effect it is easy to generate a (huge) stream of an entire volume by intermittent "dd" reads from the disk, and "dd" reads from /dev/zero, on stdout.
This would effectively be the same as catting the device itself, apart from the fact that all unused blocks have been zeroed!! That's why I call it "e2zerocat".
There are other solutions such as squashfs which is great for creating single backups but not for anything incremental wise.
In effect, you can create a sparse copy of a device by doing:
e2zerocat /dev/msata/boot | cp --sparse=always /dev/stdin outfile.sparse-dd
This will only read used blocks, and all others will be made sparse by cp.
Then you would have a sparse image file that you can mount with loopback!!.
It is just not compressed yet and I'm not sure how to accomplish that but for my purposes a sparse image of the filesystem (the entire device) is already very nice.
I mean how to mount a compressed image.
Besides, gzipping the file will un-sparsify it (it will just compress the zeroes).
So at that point I have a space efficient image.