From the TLUG mailing list
Quoth Josh Glover:
If you have two more-or-less similar machines (meaning mainly that the target machine has a hard drive at least as large as the source; the kernel seems to cope with most other differences as “trivial”, assuming you have a pretty modular one like most distros give you these days, ya damn kids!) and you want to clone one:
- Plug both machines into a fast hub, or use a Ethernet_crossover_cable (Wikipedia)
to connect them directly
- Boot up both machines from a LiveCD like Gentoo or KNOPPIX
- Bring up networking on both machines. I would advise giving them both private addresses, say 192.168.1.1 for the source and 192.168.1.254 for the target (and thus that is how my examples will work)
- Determine the device name of the hard drive on each machine. If you have an IDE (Wikipedia)
drive, your device will almost certainly be
/dev/hda
, and if you have a
SCSI (Wikipedia)
(or
SATA (Wikipedia)
? can someone confirm this) drive, it will be /dev/sda
. To verify this, run:
sudo /sbin/fdisk -l /dev/hda
or
sudo /sbin/fdisk -l /dev/sda
(Note that the option is a lowercase “L”, not the digit “one” or a capital “eye”). If you have the right drive, the output should look something like this:
Disk /dev/hda: 60.0 GB, 60011642880 bytes 255 heads, 63 sectors/track, 7296 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 13 104391 83 Linux /dev/hda2 14 7042 56460442+ 83 Linux /dev/hda3 7043 7296 2040255 82 Linux swap
- On the target machine:
HDD_DEV=/dev/sda
replace
/dev/sda
with the appropriate device name from the previous stepTARGET_PORT=2727
dd if=/dev/zero of=${HDD_DEV}
nc -l -p ${TARGET_PORT} | dd of=${HDD_DEV}
- On the source machine:
HDD_DEV=/dev/hda
Replace
/dev/hda
with the appropriate device name.TARGET_IP=192.168.1.254
Replace 192.168.1.254 with the correct IP address if you did not follow my advice because you know better. ;)
TARGET_PORT=2727
dd if=${HDD_DEV} | nc ${TARGET_IP} ${TARGET_PORT}
- Wait for a while
- Once the transfer finishes (you will know when you get dropped back to a command prompt; switch to a different virtual terminal and run
top
if you'd like to monitor the procedure--dd
andnc
processes should be consistently near the top until completion), reboot the target machine off its hard drive
dd