|
Hard drive image via Network
What is this about
This will briefly describe how to create an image of a computer's hard drive and copy it on the fly to another machine. It also provides instructions for restoring the image onto another machine.
Requirements
The procedure described here involves only basic Linux tools. I have used Knoppix for this task but any other booted Linux should do the job. You need to make sure that the hard drive you are going to backup is not mounted when you backup and restore! So it is not possible to boot the notebook with the installed Linux system. You will also need [Netcat] to pipe the image over the network. You may also use any network mounted share or another hard drive on the machine. I found it easier to just use Netcat since it does not need any setup and I do not need to add a DHCP-IP to my exports file of the server...
Note that this describes a pretty dumb backup process. You can restore the backup only on machines with a similar configuration. You must have at least as much storage capacity on the machine you are going to restore the backup on as on the backup machine! You could try some clever resizing action but I will not desribe this here.
Creating the image
- Bootup the machine via Knoppix (or any other Linux that does not run from your hard drive) and configure the network
- Make sure your hard drive (I will assume /dev/hda for now) is not mounted
- Make sure you have enough free storage capacity on the machine that will hold the image.
- For faster backups make sure that the hard drive has DMA transferred enable and is in 32-bit mode. You can check with
hdparm -cd /dev/hda and set with hdparm -c 1 -d 1 /dev/hda
- Cleanup the disk space for each partition used for better compression, e.g. using:
dd if=/dev/zero of=empty.tmp bs=1024 count=<number of free bytes>
rm empty.tmp Replace <number of free bytes< with the number of free bytes (see df output for this information)
- Start the listener on the server that will store the image:
nc -v -w 120 -p 1235 -l < /dev/null > image.gz This will run netcat in verbose mode. It will listen to port 1235 (can be any available port) for 120 seconds. It writes all incoming data to image.gz
- Start the real backup process on the backup machine within 120 seconds:
dd if=/dev/hda bs=512 | gzip -c | nc -v -w 60 <server IP> 1235 Replace the server IP accordingly. The 1235 is the port given above.
- Wait some time and have a cup of coffee
Restoring the image
Doing this on the fly
You can also try to do this without an intermediate machine that stores the image.
|
|