In this part, I’ll cover backing up your hard drive by creating a drive image with Clonezilla.
Going this route is somewhat similar to using the dd command but you go through graphical prompts instead of entering the command(s) manually
dd if=/dev/sda bs=1M | gzip -c > /mnt/sda1/hda.img.gz
Instead of typing that, which with one wrong entry could render your system unbootable or worse wipe it out, you can use Clonezilla. This is especially handy for backing up dual boot systems that contain Windows, that way if your drive dies, you don’t have to mess around reinstalling both operating systems (or the Master Boot Loader!)
Step 1 is to download the Clonezilla Live CD from their website. The software is pretty straight forward and simple to use (though you can get much more complicated and use it to push out images to remote workstations, etc.)
Once the download has finished, burn it to a cd and reboot into the Live CD to the splash screen where you should select the mode you want to run it in. Use the top item, “Clonezilla live (Default settings…)” unless you have difficulties with hardware display issues, in which case you can then try the failsafe mode which is located under the second option “Other modes of Clonezilla live“.
One thing I want to make a note of is that the below process is almost identical for saving images versus restoring an image and the fork doesn’t occur until you’re nearly at the end (I’ll point it out)
Next you’ll be prompted to select your language and keymap
Then be asked if you want to start Clonezilla or enter the shell. Unless you know the full command you want to enter (which you’ll get at the end of this process), select to “Start_Clonezilla”
Next up you’ll be asked if you want to work with images or devices. The first option is to save or restore an image (basically a file) to/from some other device, the second is essentially to clone one drive over to another. I typically select device-image. Note that one limitation of Clonezilla is that you cannot restore or clone an image or device from a larger device to a smaller one.
The next prompt asks where the image is located and give you a number of options. I’m going to assume you will be saving the image to a locally attached external hard drive, so I’ll select local_dev.
You’ll then get a text prompt telling you to plug in the external drive.
And the software will mount it automatically (your text will look different from mine since I had to pass a USB flash drive through VirtualBox)
Next is the selection of where to save or restore your image from based on the list of currently mounted devices on your machine. In my case, I want to save the drive sda in it’s entirety to the flash drive, sdb, so I’ll select sdb1.
Once you select the correct drive, you can select the directory on that drive you want to save or restore the image to or from. I want to save it to the “tmp” directory so I select that. Note that the process for restoring an image from a device is still the same.
You’ll be given a file system disk space usage screen
And be prompted to select “Beginner” or “Expert” mode. Go ahead and select “Expert” (it’s actually really easy)
This is where you will select to if you want to save the entire disk or just a single partition. Note that saving the entire disk also grabs the master boot record as well. If I’d have had an images on my device, here is where you’d fork if you wanted to restore from an image, giving you two additional prompts, one called restoredisk, the other called restoreparts.
If you are restoring an image, you’ll jump all the way to the final prompt below, else, give your image a name and select the appropriate device (if you have multiple drives in your machine) to create an image of.
You can leave the next four at the defaults. Note that sometimes you will find with certain hardware configurations that you’ll need to select different options, but try the defaults first unless you know it won’t work.
The first one asks which programs and in which order will be used to create the image (some don’t work on NTFS systems, some are slow, etc.). The second is the list of options, the most common issue I’ve run into when using Clonezilla with some drives is that I need to select the option, “Do NOT force to turn on HD DMA”. The third is the compression level for the saved images, and the fourth asks what size to split the images into (the default is 2 GB chucks)
Next, I suggest always selecting to skip checking and repairing the filesystem, ESPECIALLY if you have or are using it on an NTFS partition. And unless you are out of time for some reason, its always good to know that your backups are indeed restorable!
Finally, you’ll be asked what you want to do when finished (power off, on, nothing, etc.), be given the full command (which, if everything is exactly the same next time you create/restore an image, you can enter into the shell instead of selecting Start_Clonezilla), and be prompted to verify the image you want to create (you’ll be prompted twice if you are restoring an image, to doubly verify that you want to wipe and restore an image to a disk)
And you’re finished!
A few final notes:
- This tutorial may be long, but it only takes a minute to go through the prompts once you know what to expect
- You can only clone from a smaller to larger drive or to/from drives of the exact same size. If you need to go from a large to a smaller, you will need to resize the partitions so they are small enough to fit on the smaller disk, then image and restore them individually from the larger to the smaller disk. After that, you’ll need a linux live cd and have to restore Grub2 into the MBR so it can point to the partition loaders or to chainload Windows.
- I typically only image systems once a year or so unless I make major changes (that way a full reinstall isn’t necessary, especially with a dual-boot system), and then only have to restore files and update software