NOTICE: These forums are not active.

Image and Restore hard drives on remote computers using SSH

Share information, new uses, and creative solutions involving LiveCDs

Image and Restore hard drives on remote computers using SSH

Postby nick » Tue Feb 01, 2005 12:36 pm

I've been using this method to image hard drives (mostly Windows XP) at work. It's easy to do over the network to any computer running an SSH server, although it takes a long time. It copies all partitions and the MBR.

Step 1: Boot using any live CD with ssh and network capability (almost any live CD)

Step 2: Image the drive using the following command.

Code: Select all
dd if=/dev/hda | gzip | ssh user@serverhostname "cat > ~/backup.img.gz"

You now have a bit-for-bit hard drive image on your server. Beware, this will take a long time and not show status updates. To see status updates, open a new terminal, login and type

Code: Select all
watch ls -h backup.img.gz

This will let you watch the file size grow.

To restore the image, boot the computer from a live CD once again, and run this command:

Code: Select all
ssh user@serverhostname "cat ~/backup.img.gz" | gunzip | sudo dd of=/dev/hda bs=1024k

You can omit "sudo" if you are running as root. This will overwrite anything on the drive /dev/hda including the master boot record, so use it carefully.

There are several limitations to this method. First, it takes hours to image and restore with large hard drives. Second, you must write your image to a hard drive of the same size or larger or data may be truncated. Second, you must resize your partitions if you image to a larger hard drive. Parted and qtparted will resize many partitions on the fly, so it is useful to use a live CD which includes that program (such as Knoppix).
User avatar
Site Admin
Posts: 327
Joined: Fri Feb 20, 2004 1:35 pm

Return to LiveCD Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest