How to clone hard drives with Clonezilla

Sysadmin

Clonezilla is a Ncurses-based front-end to a set of scripts that use several open source disk utilities such as Partimage, ntfsclone, Partclone and dd. It'll jump at your command and duplicate particular partitions, or better still complete disks. It'll also restore the partitions, and help you mirror an old disk onto a bigger new disk.

Clonezilla supports a whole battalion of filesystems and then some. It can work its magic on partitions formatted as ext2, ext3, ReiserFS, XFS, JFS, FAT, NTFS, and HFS+, so you can let it rip on Linux, Windows, and Intel-based Macs. If Clonezilla encounters a partition type it doesn't understand, say Solaris's ZFS, it'll fire up the venerable dd and still get the job done. It'll constantly amaze you, so if you're looking for a bullet-proof way to backup your disks, read on...

Big on saving

Clonezilla not only saves your data, but also saves you a lot of time when doing so, by concentrating its efforts on stuff that matters - or segments of the disk that contain the data, and ignoring the blank space. But, unlike a simple data backup app, Clonezilla remembers the size of the partitions that you're asking it to clone.

So, if you have a partially used 10GB NTFS partition, you can squeeze it in a 4GB pen drive, and yet when restoring it on another disk, ask Clonezilla to create the original 10GB partition. Oh, and it can compress this data using gzip, bzip2, or lzo compression algorithms. In theory it should take a lot of time to compress the data, but on the chic dual-cores juiced with a couple of GB of RAM, you'd hardly have time to make coffee. I cloned an 80GB disk with one NTFS, one FAT, three ext3, and a Solaris ZFS partition on to a 40GB USB disk in under 20 mins. And it took less than half that time to restore.

Checklist for cloning

It's not difficult to get started with Clonezilla, but there are a few things you need before you can clone a disk or a partition, and you need to understand the process as well.

Local or Universal repository?

Clonezilla compresses the data on the partition/disk that you're cloning into an image. The most important decision in the cloning process is to select a repository where it keeps these image. You can keep them in a locally attached device, such as a USB disk attached to the computer, or on another disk on the same computer.

You can also keep the images on a computer halfway across the galaxy as long as you have network connectivity to the remote box. Clonezilla lets you communicate with an SSH server, a Samba server or an NFS file share, after prompting you for the necessary login info. When using a locally attached device, Clonezilla scans it and displays the list of disk and partitions on the device. When you're selecting a repository, make sure the disk or partition where you'll store the images is not the same one that's being cloned (the repository partition is mounted under /home/partimag).

Clone or copy?

Clonezilla can clone partitions and clone disks on the fly, but it can't do both at the same time, so you'll get the opportunity to select whether you want to create a clone image or directly clone a disk or a partition on to another disk attached to your box. Even if you wish to clone one disk on to another, you can go via the image route. When you have a working image of your disk, you can experiment with the direct disk-to-disk/partition-to-partition cloning.

Clone this, restore that

Despite all its clever options and smart behaviour, Clonezilla relies on you to select a partition for it to clone or restore. When cloning, you'll be shown a list of disks or partitions, depending on whether you selected to clone complete disks or individual partitions, at the start of the cloning process.

When restoring a partition, Clonezilla lists all the partition images it has on the repository you've pointed it at. All you have to do is find and select the partition you wish to restore. If you get this wrong, you'll have restored the wrong partition. Don't worry, there's no harm done - just restart the process and select the right image.

To compress or not to compress?

There is no straight answer to this question. If you're on a slow computer, but your repository is on a large disk, you can get through the process faster without compressing the data. If you want to back up an enormous disk/partition on to something smaller, you can select one of the three compression algorithms.

All produce different size images, with bzip2 producing the smallest. By default Clonezilla uses gzip, which balances speed and compression ratio and produces small images without much overhead.

Split images

Depending on the size of the disk/partition you're cloning, the images can be huge, despite the compression. Clonezilla offers to split them into smaller, more manageable chunks that you can burn onto optical media such as CDs and DVD. By default Clonezilla splits images into 2GB chunks, and you are free to shrink or increase this number. If you prefer one big huge chunk, select 0.

Which program to use?

Clonezilla packs a variety of programs to handle different partitions. When it sees a partition, it goes through the tools at its disposal in a particular order, and selects the most appropriate one. By default, it first lets ntfsclone have a look at the partition. If it runs into an ext3 partition, Clonezilla then calls in Partimage. If it sees a partition that Partimage can't handle, it calls in dd.

Generally you wouldn't want to mess around with the priority, but if you know you have a disk full of partitions that none of these apps can handle, you can save a bit of time and direct Clonezilla to use only dd. Or if you are feeling lucky, you can choose a priority order which calls the experimental Partclone utility before dd to back up your Mac OS X partitions.

Understand your partitions

If you don't know your hda from your sda, you'll not be able to do much with Clonezilla. If you're copying entire disks, it's also a good idea to make sure that clones of IDE disks are restored to IDE disks. It's possible to clone an IDE disk on to a SCSI disk, but it involves some command-line fun, and depending on the complexity of the disk, you might not always come out on top.

Step by step: Cloning a disk

Where to save?

Where to save? After booting the Clonezilla live CD and opting to create a clone, select where the images are saved. The 'local_dev' option saves the image on a locally attached device. To use any of the three over-the-network options, you must have the relevant connection and login details.

Disk or partitions?

Disk or partitions? Now select whether you want to clone a complete disk or just individual partitions. The 'savedisk' option clones whole disks and will later prompt you to select a disk on the computer. If you select 'saveparts' you will be asked to select the partitions you wish to clone later on.

Select the disk to clone

Select the disk to clone This is the most important step of the whole process. You'll be shown a list of disks or partitions, depending on whether you selected to clone complete disks or individual partitions. You can select multiple partitions by using the space bar.

Moving to a bigger disk

It's easy to ensure that a clone of a SCSI disk is restored to a SCSI disk, but you'll have a tough time finding an exact replica size-wise. The good news is you don't have to restore a disk on another disk of the same size. The even better news is that you can in fact restore the image to a much larger disk.

When restoring a disk, Clonezilla enables you to resize the filesystem and create partitions on the new disk proportionally. But even if you are moving to a bigger disk, you might prefer to keep the partitions as they are. In that case you can ask Clonezilla to create the partition table as its listed in the image.

Know your parameters

The programs included in Clonezilla that do the actual cloning and restoring have a few configurable parameters. Clonezilla will bring up the relevant options, after you've selected the disks/partitions to clone/restore. Don't get hassled when you see them, because Clonezilla would have marked the best (and safest) options for you.

The parameters that you should pay close attention to, are the partition and restore parameters. If you are clumsy with these parameters you'll end up wiping the MBR, or worse still nuke data on the target disk, which wouldn't probably always be new and empty. All options are clearly explained, and it'll help if you pause and think before selecting them.

Always pay close attention to the Grub and bootloader options. If you're restoring a disk on to a bigger disk, it's always a good idea to use the partition table from the disk being cloned, and you should use the option to create the new partition table proportionally. But then again, you might not always want Clonezilla to modify the MBR when restoring a disk.

Maybe you want to restore the data on to a secondary disk and prefer to modify the Grub on the primary disk to point to the distro on the restored disk. Or maybe you are restoring a partition on a disk that already has a bootloader. In this case, it's not a good idea to reinstall Grub from the image and you also shouldn't create a partition table on the disk.

Restore DVD

Once you've cloned a disk, you can copy its image to an optical media like a CD or DVD. Better still, you can ask Clonezilla to do it for you - not that Linux users have a shortage of media burning apps. But when Clonezilla creates an ISO or an image for your USB disk, it'll also pack itself on to the media. Now you'll have your disk/partition images as well as the means to restore them in one very convenient and portable location.

Step by step: Restore from a cloned image

Choose to restore

Choose to restore After you boot the live CD and select the repository containing the cloned images, you need to opt to restore an image to disk or restore an image to a partition. The recover-iso-zip option reads the image and churns out a bootable ISO image.

Select where to restore

Select where to restore Now Clonezilla displays a list of all the unmounted partitions that you can restore the image on to. Clonezilla wipes the partition and creates a new partition table on the disk, so be careful, or you'll be in trouble.

Partition parameters

Partition parameters Partitioning is the most critical step whether installing a Linux distro or restoring one from an image. Again, be very careful here, or you'll end up with a useless target disk.

Advanced CLIoning

If you think you can be efficient at low-level system administration tasks by sticking to the graphical interface, you've got another thing coming.

Like most power tools, to squeeze the most of out Clonezilla you need to cut down on the GUI and move closer to the keyboard. When you get down to cloning and restoring a disk you'll realise that you were never that far from the command line anyway.

After it's done pestering you for info through an endless series of Ncurses screens, just before it begins cloning/restoring, Clonezilla spits out a rather long command that tells you that you can use next time around. It looks something like this:

/opt/drbl/sbin/ocs-sr -q -c -gm -z1 -i 2000 -p true savedisk "2009-01-25-02-img" "hda"

Assuming you would like to repeat the operation you just did, you can issue this command at the Clonezilla prompt to avoid having to labour through all the steps. All the switches in this command reflect the options you've opted for in the GUI. For example, the -q is for the default priority, and -z1 in there points to the gzip compression algorithm. Once you get the feel for it you can also modify the command to alter minor settings like the compression algorithm to use, or more serious settings like choosing a different partition/disk.

It's a good idea to clone disks regularly, since it doesn't take much time. So the next time your hard disk decides to pack in, use your time finding the best bargain for a replacement instead of worrying about data loss.

Step by step: Cloning on the fly

Local or remote?

Local or remote? As with the normal cloning process, the first step in direct cloning is to select what you want to clone and where you want to clone it. Clonezilla can copy a local disk or partition to another locally attached disk or partition or to one accessed remotely.

Source disk/partition

Source disk/partition Next select the disk/partition you wish to clone. Unlike the normal cloning route, which creates an image, when cloning on the fly, you can only select a single disk or a single partition to clone.

Target disk/partition

Target disk/partition The next obvious step in the process is to select a disk/partition where the source disk/partition will be cloned. Stay alert when making a selection here. If you choose the wrong disk/partition, it'll be wiped clean.

First published in Linux Format

First published in Linux Format magazine

You should follow us on Identi.ca or Twitter


Your comments

Can Clonezilla be used to make disk images?

I'm not so much interested inmaking clone of hard drives, as I am in making sector level compressed disk images of drives for backup, ala Disk Image or Norton Ghost. Can Clonezilla do that?

Ext4

Clonezilla also supports ext4 now.

And thanks for the website, podcast and Linux Format mag.

On the fly?

You talk about cloning "on the fly," but never define it. What does that mean? Do you mean cloning the disk while the system is running? If so, you don't give an alternate means of how to start CloneZilla.

Will this read a disc with raid 1 mirroring on it?

I have a pair of disks that are out of my file server. They had raid 1 mirroring. Would this software skip by the raid information and read my disks?

@BubbaT - Yes Clonezilla can

@BubbaT - Yes Clonezilla can create compressed images.

@5:31pm Anon - On the fly is cloning from one drive to another by booting to the Clonezilla cd with both hard drives plugged into the system. You pick the sauce and destination and go.

RAID

Clonezilla supports hardware raid but not software raid.

So if your drives are called /sda or /hda then it should work. If your drives are /md0 then no workie.

sudo cp -r -p /olddrive

sudo cp -r -p /olddrive /newdrive

I always just use tar cvvzf

I always just use tar cvvzf /path/to/backup-file.tar.gz /path/to/partition-to-backup. But a tool like this definitely makes things more convenient for people who need advanced backup or ghosting tools.

@The poster above me: that's messy. Symlinks will disappear when copying to filesystems that don't support it and a direct copy can't be compressed. There's also more write actions on the disk as it has to create a ton of files, not just the one compressed archive or image.

Ext4 support

Clonezilla supports ext4 but all the partitions based on ext4 is cloned using DD command, and it takes a long time to complete the process. By that time we can install and setup a Ubuntu 9.10 workstation using a USB boot drive. Last week I needed to setup 10 workstations with Ubuntu 9.10 and I had installed it individually using USB boot drive as Clonezilla took a minimum of 30 mnts for cloning a 160GB HDD.

How about from 1 TB to smaller 160 G?

I have a very small amount of data on my 1TB (950G left -free) and want to use 1 Tb for something else. So my intention is to use the new 160G as target for the clone.

Can somebody show me what is the proper command?
How to invoke the "-C" dangerous mode on

command:
" /opt/drbl/sbin/ocs-onthefly -g auto -e1 auto -e2 -j2 -f sda -t sdb "

Thanks

New 160 GB Target is now showing same size as source.

I cloned my source hard drive (about 33GB) to a new 160.

The 160 is now showing the same size as the source, with very little free space and no meaningful (about 35 MB) unallocated space.

What happened to the extra 127GB????

How do I clone to a larger hard drive and have that extra space to grow into?

How do I clone to a larger hard drive and have that extra space

When restoring a disk, Clonezilla enables you to resize the filesystem and create partitions on the new disk proportionally. If it doesn't prompt you in beginner mode just go to expert mode for the restore and scroll through the settings. I'm in the middle of a backup right now so I can't check the menu.

How do I Boot from the cloned drive?

I now have a folder on my new HD which has various files in it after using Clonezilla live. How do I open these to be able to boot from this second drive now?

Cloneing to multipule drives

I am setting up an internet cafe and have about 50 PC's to setup. We are running Ubuntu as the OS and I was thinking of loading one pc with the complete os including the updates and having the desktop set as we want it and then clonening that drive to the other 49 drives. Will this work with clonezilla and will it be the best way to go?

cloned hard drive shows the same size as the source in my comput

I have a Maxtor 80G ide, 2 partitions (40G each) C&D drive which shows 38.1G each in my computer,
I installed WD Sata (II) 640G 2 partitions which shows 298G each in My Computer, labeled it S&T drive respectively. Now I used Clonezilla to Clone C drive to S drive ( I used the clone pertition to partition option) if i remember correctly its clone Hda1 to Sda1... it worked fine it cloned my C drive correctly.. only one problem.. now in my computer the S drive shows as 38.1 (even when I right click the properties) however it shows 298G in the Disk Management under Administrative Tools... How to get my System to recognize the newly cloned S drive to it's original 298G? Pls help

How to Restore from multiple DVDs

I split the partition image into 4.4 Gb segments and then stored them on individual DVDs.

Can Clonezilla restore a partition directly from the DVDs, or do I need to copy the segments into a single location (which defeats the purpose of splitting the image file in the first place)?

What about UUIDs?

Cloning implies that the cloned fileystems have the necessary adjustments to run.

Does Clonezilla have tools to adjust the Grub and fstab configurations to account for the UUID of the new partition?

Clonezilla Image clone networked hard disks

How can I backup in a network using Clonezilla:

Source hard disk (Disk_A) 60GB one single partition in network address: 192.168.1.1

Destination hard disk (Disk_B) 120GB one single partition in network address: 192.168.1.20

I want to have a cloned image of all Disk_A in Disk_B both disks are in the same network in different locations, I have ssh access to both hard disks, I can connect to machine that has DISK_A via ssh from machine that has DISK_B

How can I accomplish this?

Windows is not using all of the reported disk size

I have used Clonezilla over the last few months and I am very happy with it. The problem I am having is my original image was created from a 250gb drive. Now when I image to a 500gb drive the image works but I am only seeing 250gb avalaible and 250gb of unallocated disk space. How do I force Clonezilla to use all of the avaliable space.

clonezilla multiple local drive

is it possible to clone to MUltiple hard drives, say, 1 master 3 targets, on the same mother board,. or even an expansion card on the mother board to get up to like 8 copies at one time ?

Sorry but just doesn't work

Hi,
i have tried to clone my os partition (122gb) to a new drive (150gb), it clones everything bar the bit the drive needs to boot?

I have tried all the options at the end of the list, keep partition tables, create new ones etc, but when i plug the new drive in once the cloning completes it will not boot to win7.

Help?

I have now tried another

I have now tried another method, install windows on the new drive and try to restore my backup to that drive. The new install wont even pick up the back up file?? What the hell is with that? Thanks Windows. thats the rest of my week spent re-installing everything

Is there any sure fire way of doing this properly or not?

Copy Partition 1 Computer One => Partition 3 Computer 2

I copied /dev/sda2 on computer 1 to /dev/sdb2/restorefile (exterior usb hd).

I then tried to restore /dev/sdb2/restorefile to /dev/sda4 on computer 2.

Error message is: failed to restore partition image file /home/partimage ... /sdax to /dev/sdax maybe this image is corrupt.

computer 1 is Dell latitude 800 - Computer 2 is Dell Inspiron 1525. Different types/sizes of hard drives on each one.

How can I do this operation? Is it even possible?

Thanks in advance for help.

Rick P

I have used Clonezilla and I

I have used Clonezilla and I think it's a wonderful tool. I came across the same problem and the same error message.
If you have saved a partition into an image to disk, you can restore the image back to a same partition only.
Example: Cloning an old win/linux computer to a new linux machine.
computer 1
/dev/sda1 windows
/dev/sda2 vfat-data
/dev/sda3 linux
/dev/sda4 swap

computer 2
/dev/sda1 linux
/dev/sda2 swap

First step: save the linux partition sda3 into an image. Now, it's not possible to restore the image file to /dev/sda1 of computer 2. Take a look into the image file: some files are named <xxxx>.sda3.ext3.<yyy>. I don't know, whether it is possible to edit the image file, but I know a workaround.

Use gparted an rearrange the new computer 2 to:
/dev/sda1 linux
/dev/sda2 swap
/dev/sda3 linux

Now you can restore the image to sda3 of computer 2.
Afterwards use the 'partition to partition' clone option instead of 'partition to file'. In 'partition to partition' clone mode, you can clone sda3 to sda1. The -r option resizes the old image to the size of the new partition.

Another possible solution is the following way:
- Dismount the harddrive from computer 2.
- Connect the harddrive to a free sata-port of computer 1. If you haven't one (for example laptop) use a sata-to-USB-adapter.
- Use the 'partition to partition' clone option of clonezilla

I hope I could help.

Re: "Sorry but just doesn't work"

Windows 7 (like Server 2008) installs on 2 partitions. They create a small partition that directs the boot of the machine. Windows is then installed on the C: partition.
The only way I think a Windows 7 clone will work is by doing a complete disk to disk clone.
Another work around that might work is to do a preliminary (basic) install of Win7 with the new drive, and then use Clonezilla to do a restore of the OS partition. If that works, it would at least same the reinstalling of everything.
I'm doing some work on this very scenario with a couple of workstations in the coming weeks. I'll try to report back what I'm able to do with them.

If I did a 1:1 clone, where is my Data?

I tried to do an exact 1:1 clone with my hard drives, and went from a 150G drive to a 200G drive, and when the clone was 'done' I only had 150G available in the target drive...I don't really care about the loss of the 50Gigs..my main concerns are
1:Where is the data from my original drive or source
2:I can open the drive on the computer but there is nothing there
3:I cannot boot from it, I get a 'no NTFS' error or something similar..

My question is that if this is supposed to be an exact copy where is all the data, and are there instructions to make this a real clone? All it looks like to me is an empty Hard Drive..Please Advise.

Thanks
-Mike

powering off after using cloneziller

i have finished using cloneziller its very cool tool. but at the end it asks what do i want to do so i type in power off and i get command not known. so my question is what should i be typing.

re : powering off after using cloneziller

instead of typing the command eg "reboot" or "poweroff" choose a number 1-4 that you can see above the line saying "enter a command"

Regular Cloning

Since I test alpha and beta Ubuntu development versions and typically have 5 or 6 different versions on my 320GB laptop hard drive. I find Clonezilla a great tool for cloning my HD at least once a week. I just hook up my external sata enclosure with my extra 320GB drive inside and clone my internal drive. Only problem I have ever had is having a different Grub install in my MBR, but that is easily fixed in the terminal. I usually swap hard drives once a month just to test the cloned version. 2 thumbs up for Clonezilla Thx to Steven Shiau

Trying to resize CentOS partition after cloning

I have used the K1 option to no avail, I want to be able to resize the cloned drive after the clone is complete (went from a 40G to an 80G drive) but I have been unsuccessful at it, (i am a linux noob)

any ideas? (walkthrough would be helpful also!)

Something Went Wrong!

Hi

I am about to clone my 160GB HDD, which contains a Linux Salix OS. I have attached an external HDD which is NTFS to save the image on it. and then restore it on the new 500GB HDD. but after I pass all the blue screens and then press "y" to continue, It stops and write with red "Something went wrong". what should I do?

Content User

Most of you that state it does not work are not using it for its intended purpose. If you make an image of a Dell 800 laptop, you can only restore the image to a Dell 800 laptop. It has to have the same hardware, etc. The hardware and drivers would be completely different between different models. It will always crash.

If you have 50 Dell 800's to clone then you will see the advantage of cloning the drive. If your Dell 800 laptop crashes in six months, you can restore this saved image to the same machine or anyone like it.

CloneZilla with Multiple Partitions

The (Win7) drive I'm trying to clone to multiple systems has a boot partition, an OS partition, and a data partition. I've made images of all 3. How do I use CloneZilla to clone all 3 partitions properly to multiple drives?

Thanks.

Simple instructions please

I would like to use Clonezilla live to backup my entire hard drive to a self restoring CD or DVD. I use Ubuntu 11.10 but am fairly new to it. I am familiar with DOS from my original TI99 days and this has saved me so far with terminal commands that my terminal does't recognize, by adding complete paths for instance. I have only one CD/DVD writer and do not want to use a USB drive for any of this. Booting from a USB has it's own bugs. This is the most frequent need for a user with a home computer only. I can follow instructions just fine but am not an very experienced Ububtu user. This is also the case for many other users wanting to migrate away from windows but are scared to death of Linux. I assume this means making your computer's hard drive the target for the image file. Making the image self-restoring and then copying it to a CD or DVD. I don't find any instructions for doing this that are not cluttered up with useless information and terms I am not familiar with. Can you help? Without more novice friendly documentation and installation methods, The Linux community will not grow as it should.

Really good article

Well done to the author. This is one of the best 'how to' articles I have ever seen. Not superficial; warnings where appropriate; real step-by-step instructions & explanations.

Lewis Smith

How to Restore from multiple DVDs -Any help would be appreciated

One of the "posters" submitted this comment a while back and I didn't see an answer. This is where I am stuck. I thought I read somewhere that clonezilla has to restore from a single recovery disk..in that it won't split the image across multiple bootable disc. I NEED to find a solution that will do this. I am really hoping Clonzilla can do it, as I love the software.

Oriignal Post:
How to Restore from multiple DVDs
Anonymous Penguin (not verified) - May 6, 2010 @ 5:56pm

I split the partition image into 4.4 Gb segments and then stored them on individual DVDs.

Can Clonezilla restore a partition directly from the DVDs, or do I need to copy the segments into a single location (which defeats the purpose of splitting the image file in the first place)?

OSX 10.7+ : Mac Pro apple's 1TB to not-apple 256g SSD

Apple wants $800 for new Mac Pro SSD option. I picked 1 TB and bought better performing and LESS costly SSD on amazon. Both cases SSD smaller than 1TB.

Here's hoping simple mode disk-to-disk cloning will give all needed joy

Clone disk with RTMOS filesystem ?

I tried to clone a scsi 1GB Quantum Fireball HDD to a Seagate 10GB HDD (SCSI HDD has the RTMOS Operaating System from General Electrics) using dd (as for the unknown filesystem) in sector-to-sector and disk-to-disk mode but the cloned (ide) drive does not boot. The drives are both 100% functional.

What is wrong?

Clone disk with RTMOS filesystem ?

...the Seagate 10GB HDD is an IDE disk.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

CAPTCHA
We can't accept links (unless you obfuscate them). You also need to negotiate the following CAPTCHA...

Username:   Password:
Create Account | About TuxRadar