Dec 14, 2010

Linux System Cloning using "dd"

First check the partition table first using following command
fdisk -l

Device Boot Start End Blocks Id System
/dev/sda1 1 9 72261 83 HPFS/NTFS
/dev/sda2 10 75 530145 82 Linux swap
/dev/sda3 76 467 3148740 fd Linux raid autodetect
/dev/sda4 468 2200 13920322+ 83 Linux

Simple but may take a lot of time ( over 10 hours is no surprise)
dd if=/dev/sda of=/dev/sdb

If you think there is no point in cloning swap areas and empty partition, clone each partition

Note: Both drives are partitioned exactly same. If you have different brand harddrives, make sure each partition on second drive must be equal to or greater than first drive partitions. Also make sure File system ID should match for second drive also.

dd if=/dev/sda of=/dev/sdb bs=446 count=1
dd if=/dev/sda1 of=/dev/sdb1 ==> Clone NTFS partition
dd if=/dev/sda3 of=/dev/sdb3 ==> Clone RAID-1 partition