Clone hard disk over network
Posted: 2007-11-24. Updated: 2013-03-23.
What: Cloning a hard disk using an IP network and only standard
Unix tools, such as dd
and nc
(abbreviation for
netcat).
Purpose: When upgrading your hard disk you usually want to clone the
original content on the old disk onto the new disk.
Cloning a hard disk drive (hdd) via an IP network using only standard
Unix tools like dd
and nc
is really easy,
straightforward and well documented. However there are some small, but
grave difficulties to be aware of, which are usually not mentioned
elsewhere.
Client: Computer where the hdd needs to be cloned.
Server: Computer with enough hdd space to host a full disk image of
Client's old hdd. Reachable via IP network.
- Use some Linux live CD, for example Knoppix to boot Client.
- Connect Client and Server via IP network.
- Transfer old hdd image to Server:
Server:$ nc -l -p $Port -w 300 > $File
Client:# dd if=/dev/hda | nc -w 300 $Server_IP $Port
- Check success:
Client:# md5sum /dev/hda
Server:$ md5sum $File
- Client: Remove the old hdd and install the new one.
- Zero the beginning of the new hdd to initialize the disk (optional,
but recommended):
Client:# dd if=/dev/zero of=/dev/hda bs=1M count=1024
- Transfer old hdd image onto new disk:
Client:# nc -l -p $Port -w 300 | dd of=/dev/hda
Server:$ cat $File | nc -w 300 $Client_IP $Port
So remember to set the option "-w $Wait
"!
Here we chose $Wait
to be an arbitrarily large timeout of
300 seconds to be on the safe side. Otherwise the data transfer back onto
Client's new hdd stops unexpectedly and reproducible at around 80% (32GB)
when using our LAN and even while directly connected. This caused serious
head scratching, quite some wasted time and it is still a bit unclear to us
why this option is needed on such a fast connection. Feel free to
enlighten us.
To increase the partition size after the cloning onto the new and probably larger disk, the live CD of GParted worked well.
Back to writings.