Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!
niemueller.de::home niemueller.de
Open Software. Open Knowledge.




 

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

  • Bootup the restore machine via Knoppix (or any other Linux that does not run from your hard drive) and configure the network
  • All data on the restore machine will be destroyed!
  • Make sure the hard drive capacity is greater than or equal to the hard drive capacity of the backup machine
  • Start the feeder on the server:
    cat image.gz | nc -v -w 120 -p 1236 -l
  • Start the restore process on the restore machine:
    nc -v -w 60 <server ip> 1236 < /dev/null | gzip -dc | dd of=/dev/hda bs=512
    Replace server ip with the IP from the feeder.
  • Wait some time and have a cup of coffee.
  • Reboot the restore machine and accept the fsck errors.


Doing this on the fly

You can also try to do this without an intermediate machine that stores the image.
  • On the listening restore machine execute:
    nc -v -w 120 -p 1237 -l < /dev/null | gzip -dc | dd of=/dev/hda bs=512
    Note: This will destroy ALL data on the restore machine!
  • On the feeding backup machine execute:
    dd if=/dev/hda bs=512 | gzip -c | nc -v -w 60 <server ip> 1237
    This will copy all information over the network to the restore machine.
  • Now have a cup of coffee again, then reboot and see fsck complaining.
    Home     Contents     Search     View other revisions     Recent changes    




Top 5 Pages
Wiki
WebLog
SquidGuard Webmin Module
Network Utilities Webmin Module
IPtables Webmin Module


Palm Software
UniMatrix UniMensa UniSorter
UniChat OHS Mobile Onager


My Bookshelf




Valid XHTML 1.1!

RSS Copyright © 2000-2009 by Tim Niemueller