Imaging a Hard Drive using ssh and dd

Image hard drive to remote ssh server.

Requirements

  • A 'Live' CD distrobution like knoppix
  • Access to remote ssh server
  • Enough space to store the imag

Process : Make changes where necessary to match your system setup.

#Boot from the live cdrom distribution.
#Switch to root
#Make sure ''NO'' partitions are mounted from the source hard drive.

In order to do this in the VMWare virtual machine I was copying I used a Knoppix bootable CD so that I could access /dev/sda without having it mounted but still have access to a shell with full networking and ssh.  Configure networking and from a shell enter the following:

#dd if=/dev/sda | ssh paul@192.168.123.120 /bin/dd of=/vm/LTSP_Legacy_Master.img
If you want to compress the image, use gzip, making necessary changes for your system :
dd if=/dev/sda | gzip --fast -c | ssh paul@192.168.123.120 /bin/dd of=/vm/LTSP_Legacy_Master.img.gz
This took about 1.5 hours to copy a 10GB HDD over a 100MB WAN....
Restore hard drive from remote ssh server.

Requirements:

  • A 'Live' CD distrobution like knoppix
  • Access to remote ssh server
  • Hard drive with equal or greater capacity than the hard drive image

Process: Make changes where necessary to match your system setup.

Boot from the live cdrom distribution.
Switch to root
Make sure NO partitions are mounted from the source hard drive.
# ssh paul@192.168.123.120 cat /vm/LTSP_Legacy_Master.img | dd of=/dev/sda''
If you used gzip for compression, instead execute the following command, making necessary changes for your system :
# ssh paul@192.168.123.120 zcat /vm/LTSP_Legacy_Master.img.gz | dd of=/dev/sda
Using dd on a locally mounted drive is even easier.

Requirements:

  • 2 hard drives on a linux system.
  • dd
Find which device node your drives are using. fdisk will show you the drive geometry. Be carefull not to esare anything though.

Clone a disk:

# dd if=/dev/sda of=/home/paul/SiteKiosk.img

Restore a disk:

# dd if=/home/paul/SiteKiosk.img of=/dev/sda