Simple Ubuntu Server: Part 4b – Backing Up Your Machine with Clonezilla

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)

Clonezilla splash screen

Clonezilla splash screen

Next you’ll be prompted to select your language and keymap

Language selection

Language selection

Keymap selection

Keymap selection

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”

Clonezilla or shell prompt

Clonezilla or shell prompt

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.

Image or device

Image or device

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.

Image location

Image location

You’ll then get a text prompt telling you to plug in the external drive.

Plugin external drive now

Plugin external drive now

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)

Device is attached and mounted

Device is attached and mounted

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.

Device-image location

Device-image location

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.

Select device directory

Select device directory

You’ll be given a file system disk space usage screen

File system disk space usage

File system disk space usage

And be prompted to select “Beginner” or “Expert” mode. Go ahead and select “Expert” (it’s actually really easy)

Beginner or expert mode

Beginner or expert mode

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.

Save disk or partition

Save disk or partition

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.

Image name

Image name

Select disk to save

Select disk to save

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)

Program priority

Program priority

Program options

Program options

Compression level

Compression level

Image size

Image size

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!

Check and repair filesystem

Check and repair filesystem

Check if image is restorable

Check if image is 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)

What to do when finished

What to do when finished

Full command

Full command

Start restore?

Start restore?

And you’re finished!

A few final notes:

  1. This tutorial may be long, but it only takes a minute to go through the prompts once you know what to expect
  2. 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.
  3. 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
Tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

Protected by WP Anti Spam