Dump/restore to clone disk

Polytropon freebsd at edvax.de
Mon Feb 22 09:15:53 UTC 2010


On Mon, 22 Feb 2010 16:33:47 +0800, Aiza <aiza21 at comclark.com> wrote:
> I have seen this posted in the questions archives to be
> used to clone a active system hard drive to a
> USB cabled hard drive.
> 
> 
> 
> Prepare the target
> #dd if=/dev/zero of=/dev/da0 count=2
> # fdisk -BI /dev/da0
> # bsdlabel -B -w da0s1
> # newfs –U /dev/da0s1a               # /
> # newfs -U /dev/da0s1d               # /var
> # newfs -U /dev/da0s1e               # /tmp
> # newfs -U /dev/da0s1f               # /usr
> 
> Mount target file system ‘a’
> # mount /dev/da0s1a /mnt
> # cd /mnt
> # dump -0Lauf - /dev/ad1s1a  | restore -rf -
> # cd /
> # umount /mnt
> 
> Mount target file system ‘d’
> # mount /dev/da0s1d /mnt
> # cd /mnt
> # dump -0Lauf - /dev/ad1s1d  | restore -rf -
> # cd /
> # umount /mnt
> 
> Mount target file system ‘e’
> # mount /dev/da0s1e /mnt
> # cd /mnt
> # dump -0Lauf - /dev/ad1s1e  | restore -rf -
> # cd /
> # umount /mnt
> 
> Mount target file system ‘f’
> # mount /dev/da0s1f /mnt
> # cd /mnt
> # dump -0Lauf - /dev/ad1s1f  | restore -rf -
> # cd /
> # umount /mnt

I'd like to suggest "successive" mounting of the partitions.
E. g. as they are "nested" on the source disk, this can be
done on the target disk, too.

	# mount /dev/ad1s1a /mnt
	# cd /mnt
	# dump -0 -f - /dev/ad0s1a | restore -r -f -

	# mount /dev/ad1s1e /mnt/tmp
	# cd /mnt/tmp
	# dump -0 -f - /dev/ad0s1e | restore -r -f -

	# mount /dev/ad1s1f /mnt/var
	# cd /mnt/var
	# dump -0 -f - /dev/ad0s1f | restore -r -f -

	# mount /dev/ad1s1g /mnt/usr
	# cd /mnt/usr
	# dump -0 -f - /dev/ad0s1g | restore -r -f -

	# mount /dev/ad1s1h /mnt/home
	# cd /mnt/home
	# dump -0 -f - /dev/ad0s1h | restore -r -f -

And then:

	# cd /
	# umount /mnt/home
	# umount /mnt/usr
	# umount /mnt/var
	# umount /mnt/tmp
	# umount /mnt
	# sync
	# halt

In the above example, transfer is going from ad0 to ad1.



> I have questions about this method.
> 
> What happened to swap? The fstab will be showing it as
> the first file system on the hard drive slice.
> Is something missing here?

The swap partition does not need to be cloned. Furthermore,
I doubt that it is the first partition on the disk, while
it MAY be possible that it is the first entry in /etc/fstab.

The root partition usually refers to partition a, while
the swap partition refers to b.



> What about the file system sizes.
> Will the restored hard drive have the same
> file system sizes as the source file system?

The target partitions should be at least as big as the
source partitions, and they will be filled up to the
point the source partition has data, e. g. partition
/usr is 20 GB and has 10 GB data, and it is dumped and
restored to a new /usr partition with 30 GB space
available, then this new partition will be occupied
1/3 (with 10 GB).



> Is there some way to allocate larger file systems
> on the target without using sysinstall to prepare
> the target beforehand?

Yes, "sade" is such a tool, as well as the usual method
of using fdisk, bsdlabel, and newfs.



> Is there some command to display
> the file system allocation size?

You can always use df -h for this, e. g.

	% df -h /var
	Filesystem     Size    Used   Avail Capacity  Mounted on
	/dev/ad0s1e    989M    384M    527M    42%    /var

THis should inspire you how to dimension the new partition.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list