If you would like to backup your hard disk, there is a simple way to do it by using "dd" command. The dd command utility is used to copy files or disk images from one location to another. Using dd, you can backup an unmounted disk as a (compressed) disk image which is then stored in a separate local or remote disk. Here is how to backup and restore a hard drive using dd command.
In order to use dd to backup a hard disk, you should unmount the disk first. A mounted hard disk may have various filesystem activities, and dd'ing such a live system may capture partial writes, which can lead to corrupted disk image. If the disk you want to backup corresponds to the root partition, you can boot from a Linux Live CD, and proceed to back up the root partition while it is not mounted. When a disk is unmounted, you can backup the disk as follows.
The above command makes a clone of /dev/sda, gzips it, and stores the compressed image in /mnt/disk1. To restore the saved disk image, you can do the reverse:
If you would like to backup a local hard drive on to a remote host, you can do the following.
The above commands does disk cloning, compresses it, and then securely transfers the gzipped image to a remote host. To restore the disk image from the remote location, do the reverse as follows.
For more advanced disk image backup/recovery options, check out Clonezilla.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!