[blfs-support] Complete Backup of {,B}LFS

Aleksandar Kuktin akuktin at gmail.com
Sun Dec 22 15:43:13 PST 2013


>On Sun, 22 Dec 2013 16:23:49 -0600
>Dan McGhee <beesnees at grm.net> wrote:
>
> On 12/22/2013 03:25 PM, Aleksandar Kuktin wrote:
> > 
> > [snip]
> > 
> > $ mkdir /mnt/stuff
> > $ mount /dev/of/root /mnt/stuff
> > $ mount /dev/of/usr /mnt/stuff/usr
> > $ cd /mnt/stuff
> > $ find . -print0 > /tmp/list
> > $ cpio -p -0md --sparse /mnt/destination < /tmp/list
> >
> > That should collect everything and give you the result which is as
> > close as you can get without cloning the underlying
> > device/filesystem.
> >
> This looks really interesting and I want to "play" with it. But what
> I want *is* a clone, an exact copy, of what I have now.
> 
> Dan
> 

Well, in that case, dd is probably your friend.

dd if=/dev/source of=/dev/destination bs=512

Ofcourse, this only works if the destination partition is at least as
big as the source partition. For best results, the two should be
identical. If destination is bigger than the source, the extra space
in the destination will be unused. I think I read somewhere that some
program from e2fsprogs can be used to resize ext2/ext3 filesystems, but
don't take my word for it. The other way of reclaiming the dead space
is to resize partitions however this is a very touchy procedure, may
not work on EFI/UEFI systems (depending on how they actually physically
store partition information) and requires manually calculating offsets
and filesystem and partition sizes. I did this once or twice (including
recovering my HDD after accidentally overwriting the partition table)
and can walk you through the process, but unless you *need* or *want*
the modification timestamps on you directories to be exactly the same
as on the original filesystem, you are much better off using cpio.

Note that you can also clone devices with cat (and probably a host of
other even more convoluted methods):
cat < /dev/source > /dev/destination
...but dd is better because it prints out exact statistics on what it
did while cat either prints nothing at all or just spits out a terse
and not entirely informative error string.

On the subject of cloning filesystems (as opposed to cloning devices),
I come up blank with names of programs that can do that, even though
there is probably at least one program that can do that.


Ow, and one other thing: if the destination is a raw flash memory
device (the kind you can find in Android phones), don't use either dd
or cat because raw flash needs to be written accoding to a special
protocol. There are specialized programs that do that, and you should
use one of those.

-- 
You don't need an AI for a robot uprising.
Humans will do just fine.



More information about the blfs-support mailing list