Linux.com

Home Learn Linux Linux Tutorials How to Image and Clone Hard Drives with Clonezilla

How to Image and Clone Hard Drives with Clonezilla

fig-1 gparted

Clonezilla is a partition and disk cloning application for Linux, Free-, Net-, and OpenBSD, Mac OS X, Windows, and Minix. It supports all the major filesystems including EXT, NTFS, FAT, XFS, JFS, and Btrfs, LVM2, and VMWare's enterprise clustering filesystems VMFS3 and VMFS5. Clonezilla supports 32- and 64-bit systems, both legacy and UEFI BIOS, and both MBR and GPT partition tables. It's a good tool for backing up a complete Windows system with all of your installed applications, and I like it for making copies of Linux test systems so that I can trash them with mad experiments and then quickly restore them.

Clonezilla can also copy unsupported filesystems with the dd command, which copies blocks rather than files, so it doesn't need to understand filesystems. So, the short story is Clonezilla can copy anything. (A quick note on blocks: disk sectors are the smallest addressable storage units on hard disks, and blocks are logical data structures made up of single or multiple sectors.)

Clonezilla comes in two versions: Clonezilla Live and Clonezilla Server Edition (SE). Clonezilla live is ace for cloning single computers to a local storage device or network share. Clonezilla SE is for larger deployments, and fast multicast cloning an entire network of PCs at once. Clonezilla SE is a wonderful bit of software that we shall cover in the future. Today we shall create a Clonezilla Live USB stick, clone something, and restore it.

Clonezilla and Tuxboot

When you visit the download page you'll see Stable and Alternative Stable releases. There are also Testing releases, which I recommend if you're interested in helping to improve Clonezilla. Stable is based on Debian and includes no non-Free software. Alternative Stable is based on Ubuntu, includes some non-Free firmwares, and it supports UEFI Secure Boot.

After you download Clonezilla, install Tuxboot to copy Clonezilla to a USB stick. Tuxboot is a modification of Unetbootin that supports Clonezilla; you can't use Unetbootin because it won't work. Installing Tuxboot is a bit of pain, though Ubuntu users can install Tuxboot the easy way from a personal packages archive (PPA):

$ sudo apt-add-repository ppa:thomas.tsai/ubuntu-tuxboot
$ sudo apt-get update
$ sudo apt-get install tuxboot

If you're not running Ubuntu and your Linux distribution doesn't include a packaged version of Tuxboot, download the source tarball and follow the instructions in the README.txt file to compile and install it.

Once you get Tuxboot installed, use it to create your nice live bootable Clonezilla USB stick. First create a FAT32 partition of at least 200 megabytes; figure 1 (above) shows how it's done in GParted. I like to use labels, like "clonezilla", so I know what it is. This example shows a 2GB stick formatted as a single partition.

Then fire up Tuxboot (figure 2). Check "Pre-downloaded" and click the button with the ellipsis to select your Clonezilla file. It should find your USB stick automatically, and you should check the partition number to make sure it found the right one. In my example that is /dev/sdd1. Click OK, and when it's finished click Exit. It asks you if you want to reboot now, but don't worry because it won't. Now you have a nice portable Clonezilla USB stick you can use almost anywhere.

fig-2-tuxboot

Creating a Drive Image

Boot up your Clonezilla USB stick on the computer that you want to backup, and the first thing you'll see is a normal-looking boot menu. Boot to the default entry. You'll be asked language and keyboard questions, and when you arrive at the Start Clonezilla menu select Start Clonezilla. In the next menu select device_image, then go to the next screen.

This screen is a little confusing, with options for local_dev, ssh_server, samba_server, and nfs_server. This is where you select the location for your backup image to be copied to. The size of your destination partition or drive must be the same size or larger than the volume you're copying.  If you choose local_dev, then you'll need a local partition with enough room to store your image. An attached USB hard drive is a nice fast and easy option. If you choose any of the server options you'll need a wired Ethernet connection, the IP address of your server, and your login. I'll use a local partition, which means selecting local_dev.

When you select local_dev Clonezilla scans all of your locally-attached storage, including hard disks and USB storage devices, and makes a list of your partitions. Select the one you want to store your new image in, and then it asks which directory to use and shows you a list. Select your desired directory, and the next screen shows all of your mounts and used/available space. Press Enter, and the next screen gives you the option of Beginner or Expert mode. I choose Beginner.

In the next screen you can choose savedisk, which creates an image of an entire hard disk, or save_parts, which allows you to select individual partitions. I want to select partitions.

The next screen asks for a name for your new image. After accepting the default or entering your own name, go to the next screen. Clonezilla scans your partitions and creates a checklist so you can pick the ones you want to copy. After making your selections, the next screen gives you the option to do a filesystem check and repair. I'm impatient, so I skip this part.

The next screen asks if you want Clonezilla to check your newly-created image to make sure it is restorable. I always say yes. Next, it gives you a command-line hint in case you ever want to use the command-line instead of the GUI, and you must press Enter again. You get one more confirmation, and then type y for Yes to make the copy.

You get to watch a nice red, white, and blue progress screen while Clonezilla creates your new image (figure 3).

fig-3 export

When it's all finished press Enter and then select reboot, and remember to remove your Clonezilla USB stick. Boot up your computer normally, and go look at your nice new Clonezilla image. You should see something like this:

$ ls -l /2014-08-07-11-img/
total 1241448
-rw-r--r-- 1 root root       1223 Aug  7 04:22 blkdev.list
-rw-r--r-- 1 root root        636 Aug  7 04:22 blkid.list
-rw-r--r-- 1 root root       3658 Aug  7 04:24 clonezilla-img
-rw-r--r-- 1 root root      12379 Aug  7 04:24 Info-dmi.txt
-rw-r--r-- 1 root root      22685 Aug  7 04:24 Info-lshw.txt
-rw-r--r-- 1 root root       3652 Aug  7 04:24 Info-lspci.txt
-rw-r--r-- 1 root root        171 Aug  7 04:24 Info-packages.txt
-rw-r--r-- 1 root root         86 Aug  7 04:24 Info-saved-by-cmd.txt
-rw-r--r-- 1 root root          5 Aug  7 04:24 parts
-rw------- 1 root root 1270096769 Aug  7 04:24 sda6.ext4-ptcl-img.gz.aa
-rw-r--r-- 1 root root         37 Aug  7 04:22 sda-chs.sf
-rw-r--r-- 1 root root    1048064 Aug  7 04:22 sda-hidden-data-after-mbr
-rw-r--r-- 1 root root        512 Aug  7 04:22 sda-mbr
-rw-r--r-- 1 root root        750 Aug  7 04:22 sda-pt.parted
-rw-r--r-- 1 root root        625 Aug  7 04:22 sda-pt.parted.compact
-rw-r--r-- 1 root root        514 Aug  7 04:22 sda-pt.sf

Restoring a Clonezilla Image

Restoring your image is similar to creating it. Again, boot up Clonezilla, go through the same initial steps, select dev_image, and then on the local_dev screen select the location of your image that you want to restore, whether it's on a local device or network share. Then continue through the rest of the screens, making sure that you have the correct restore image and target locations selected.

You can learn more of Clonezilla's amazing powers at the Clonezilla Live Documentation page.

 

Comments

Subscribe to Comments Feed
  • Scott Said:

    I just did this a couple of days ago to P2V a linux laptop to keep as a VM on my new laptop. Easy peasy.

  • Solish Said:

    I am using clonezilla for long time to back up arcade games hard disk.whether it's Linux or windows this is the best stable tool I used.there is similar trusted backup tool I used "road kill raw file copie" and easos to do back up.

  • Chris Kjølbo Said:

    Hi. What if the destination drive is smaler than the source ? I have real problems in this case. The checkmark to self adjust the destination size doesent work. Have tried within stabel and 1 developper edition, from about 3 month ago. ? Regards Chris

  • Carla Schroder Said:

    Hi Chris, The destination drive must be equal or greater in size than the source. I have corrected the article to say this.

  • Mike Said:

    I've had some success cloning to a smaller drive using the 'Advanced Options'. The Clonezilla website states, "If you are sure all the data from the image could fit the smaller disk, i.e. it won't be written to the wrong disk space, you can check the option "-icds".Warning! To select this option, you have to know what you are doing!" http://clonezilla.org/clonezilla-live/doc/02_Restore_disk_image/advanced/09-advanced-param.php

  • sheesh Said:

    What's wrong with using dd? You need a GUI?

  • PhilQ Said:

    @Sheesh: dd is a bitcopier, Clonezilla uses partmage/partclone to save/compress the files in a partition. The resulting images are much smaller as it does not dumbly copy the entire disk, which is what dd does. It also knows to limit the image files to 2GB, so FAT thumb drives can be used to back up much larger disks (you get multiple 2GB files, plus the leftover). Yes you could drive the commands yourself but why bother when you can use this instead.

  • PhilQ Said:

    @Sheesh: dd is a bitcopier, Clonezilla uses partmage/partclone to save/compress the files in a partition. The resulting images are much smaller as it does not dumbly copy the entire disk, which is what dd does. It also knows to limit the image files to 2GB, so FAT thumb drives can be used to back up much larger disks (you get multiple 2GB files, plus the leftover). Yes you could drive the commands yourself but why bother when you can use this instead.

  • gnumber9 Said:

    when i spent a couple of months with gentoo, clonezilla was a priceless tool and since then i use it to make images. however making a bootable usb stick was an interesting process. i tried dd and this never worked. dd is how i make my arch boot sticks. i tried tuxboot and it never worked. unetbootin does not seem to work on arch for anything, so i used unetbootin in debian and windows and it makes clonezilla usb boot media fine. i know the instructions say otherwise, i've used linux since 99 and perhaps i am in an alternative universe, but this is how making usb media worked for me. one note is that clonezilla's boot menus have a green/red color scheme and it looks pretty wild.

  • tragicallyhip Said:

    Unetbootin works perfectly for deploying Clonezilla, in fact it was Tuxboot as recommended in this tutorial that did not function as advertised

  • Rich Namen Said:

    I had problems with USB drives also - switched to Rufus, a Windows Only tool, to make all of my bootable USBs. It sucks that I have to use Windows but it is rock solid. Rufus uses the ISO to create the boot partition O/S so if you are doing a windows ISO it boots in Windows and if your are doing Linux it boots Grub. http://rufus.akeo.ie/


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board