How to duplicate a complete PC via network
This documentation started in 2001 when standard hard discs often
still were measured in MB (MegaBytes) instead of GB. For today's discs
approaching TerraBytes you'll need a sufficiently sized network:
transferring TBs we're talking about hours or days when using a 1
Gbit/s or (ouch so painful) slower network. Likewise it now is
completely unpractical to use it as backup means for bigger partitions
(e.g. like images on DVDs). For a pure system backup filesystem-aware
images like partimage, g4u, Norton Ghost or similar are better due to
their reduced image size.
In contrast to these DD still is superiour when it comes to creating a
forensic image. Or when the ghost doesn't recognize your file system,
or similar. So here's how to do with on-board tools.
Nowadays (in contrast tp 2001) all CPUs are fast enough to do compression
while still saturating a 1Gbit/s connection. If possible, use 10Gbit/s
networks - at least for the server used to store the images.
One possible problem you might encounter is that FAT filesystems won't
do more than 2GB image size, so choose an appropriate file system type
on the server.
Requirements:
- Two or more identical PCs that are supported by the
- Boot media (floppy, CD or USB stick) that can handle the hardware
as well as the wanted filesystems, e.g. grml, PuppyLinux or the
oldie-but-goldie TRBT floppy (http://www.toms.net/rb/).
Make sure you're logged in as ROOT user.
- Optonal an "image server" for central storage of the (different)
image files - thus need for enough disk space.
- Network infrastructure for the PCs - a simple crosslink cable
often is enough - is using an image server, a switched
environment is preferrable.
- The netcat program - usually it is called "netcat", but some other
distributions call it "nc"
- If your harddisc is broken, use "dd_rescue"
(http://www.garloff.de/kurt/linux/ddrescue/
which will skip read errors. This way you can (try to) rescue data
from a broken disc when simple TARing won't do anymore.
Create the image:
- Install and configure the master PC (i.e. the PC to be imaged)
- Cleanup the disk space for each partition used for better
compression, e.g. using:
dd if=/dev/zero of=empty.tmp bs=1M
rm empty.tmp
- Start command on the image server to accept the image on an
arbitrary TCP port (usually above 1024):
netcat-v -w 120 -l PORT < /dev/null > image.gz
Some old Netcat versions need the parameter combination "-l -p
PORT" as the meaning of the "-p" parameter changed.
- Within 120 seconds start sending the image from the master PC to
the image server:
dd if=/dev/hda bs=512 | gzip -c | netcat-v -w 60 SERVERIP PORT
Flatten the "virgin" PC and impress the image:
- WARNING! This will utterly destroy each and all data on the PC
involved!
- Boot with independent media and configure the network
- Prepare the image server to send the image:
cat image.gz | netcat-v -w 120 -l PORT
- Fetch image and impress it onto the PC's harddrive:
netcat-v -w 60 SERVERIP PORT < /dev/null | gzip -dc | dd of=/dev/sda
- Reboot and accept the complaining FSCK which will run and correct
without problems.
Copy PC On-the-Fly without using an image server
- WARNING! This will utterly destroy each and all data on the PC
involved!
- Boot client with independent media and configure the network
- prepare the client to accept the image and write it directly to
the disk:
netcat-v -w 120 -l PORT < /dev/null | gzip -dc | dd of=/dev/hda bs=1M
- Send the image from the master:
dd if=/dev/sda bs=1M | gzip -c | netcat-v -w 60 SERVERIP PORT
- Reboot and accept the complaining FSCK which will run and correct
without problems.