Clone a running FreeBSD system to another disk. Source drive: ad0
, target drive ad1
Prepare the target drive
cd /tmp/
df -h > liveFSsizes
bsdlabel da0s1 > liveSPsizes
dd if=/dev/zero of=/dev/da1 count=2
fdisk -BI /dev/da1
bsdlabel -B -w da1s1
bsdlabel -R da1s1 liveSPsizes
cat liveSPsizes
newfs -U /dev/da1s1a
newfs -U /dev/da1s1d
newfs -U /dev/da1s1e
newfs -U /dev/da1s1f
Mount each partition and dump the source partition (da0
) to our backup (-
)
mount /dev/da1s1a /mnt
cd /mnt
dump -0Lauf - /dev/da0s1a | restore -rf -
mount /dev/da1s1d /mnt/var
cd /mnt/var
dump -0Lauf - /dev/da0s1d | restore -rf -
mount /dev/da1s1e /mnt/tmp
cd /mnt/tmp
dump -0Lauf - /dev/da0s1e | restore -rf -
mount /dev/da1s1f /mnt/usr
cd /mnt/usr
dump -0Lauf - /dev/da0s1f | restore -rf -
sync
cd /tmp
rm liveSPsizes
rm liveFSsizes
umount /mnt/usr
umount /mnt/tmp
umount /mnt/var
umount /mnt
Note when you fdisk
you should expect the following errors:
******* Working on device /dev/da1 *******
fdisk: Class not found
The original version of this can be found on the FreeBSD fora in this thread: http://forums.freebsd.org/showthread.php?t=11680.
Written on 17 Jan 2011 and categorised in FreeBSD, tagged as Backup, dump, and restore