Theodoros Emmanouilidis

Notes & Thoughts

Clone Entire Hard Drive With dd

February10

Suppose you want to back-up your entire system hard drive to a remote location as an image that you can roll back your system in case of emergency or copy everything to a new hard drive that will substitute the original system drive that is failing.

The following command clones entire hard drive with dd. First of all you need to boot your machine using a live Linux distro like knopix. Then, supposing that the hard drive you want to clone is sda, give the command

1
dd if=/dev/sda | gzip -1 - | ssh username@remotehost dd of=backup_image.gz

If you want to recover the image give the following command

1
dd if=backup_image.gz | gunzip -1 - | dd of=/dev/sda

dd copies everything bit by bit which means that the whole process takes a very long time. The good thing is that the cloned image is exact, containing original disk’ s partition info, boot sector info, everything.

It helps out though, in terms of speeding up the process a bit, to zero out all unused space, before using dd, issuing the command

1
dd if=/dev/zero of=0bits bs=20M; rm 0bits

Better be safe than sorry!

posted under Tip Of The Day | Comments Off on Clone Entire Hard Drive With dd