| English | 日本語 |

Tokyo Linux Users Group

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:

  1. Plug both machines into a fast hub, or use a Ethernet_crossover_cable (Wikipedia)

to connect them directly

  1. Boot up both machines from a LiveCD like Gentoo or KNOPPIX
  2. 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)
  3. 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
  1. On the target machine:
    1. HDD_DEV=/dev/sda

      replace /dev/sda with the appropriate device name from the previous step

    2. TARGET_PORT=2727
    3. dd if=/dev/zero of=${HDD_DEV}
    4. nc -l -p ${TARGET_PORT} | dd of=${HDD_DEV}
  2. On the source machine:
    1. HDD_DEV=/dev/hda

      Replace /dev/hda with the appropriate device name.

    2. 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. ;)

    3. TARGET_PORT=2727
    4. dd if=${HDD_DEV} | nc ${TARGET_IP} ${TARGET_PORT}
  3. Wait for a while
  4. 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 and nc processes should be consistently near the top until completion), reboot the target machine off its hard drive

dd