Thursday, January 29, 2009

On Cloning a Hard-Drive: The Problem

Over the past three years I have had the worst luck with computers: 2 system board crashes due to unknown issues, one system board crash due to an accident involving some water and an ethernet cable, two or three hard-drive failures, wireless drivers that mysteriously stop working and won't allow you to uninstall/reinstall.

The common theme to all of these issues, is that I've almost always lost at least a weeks worth of work trying to get back up to speed, re-installing the OS and software, configuring a development environment, downloading email, etc.

Needless to say, I either need to stop using computers or figure out a backup/cloning strategy.

For now, I chose the latter.

I just finished setting up Ubuntu Intrepid 8.10 on my laptop. I installed Eclipse, MySQL, Tomcat, Java, downloaded email, blah blah blah ...

So now, I want to clone this hard-drive so I can swap in the cloned drive if the first drive ever fails. I will clone the primary drive onto the second drive once a week (or more often if I can find some software to manage it for me).

I currently use Acronis True Image Home 11 for my backups, but for some reason it does not allow me to clone the drive. After contacting Acronis "support" a few times, I have decided to start looking for an open-source solution to the problem.

On Cloning a Hard-Drive: The Solution

Thanks to Renaud and Jim for their input.

Jim - At some point I'll adopt a "constant backup" solution (using an online service or local backup server), but for the time being, I think I found a winner.

So I want to clone the hard-drive (source) that I've spent the past few days configuring onto a second drive (target) so that I can swap the two drives without worrying about reinstalling applications, reconfiguring email accounts, etc. The idea is that I will clone the source drive onto the target drive at least once a week so that I can stay up-to-date with Ubuntu patches and packages. And if something goes wrong with the source drive, I can plug the target drive in and I'll be ready to go. I'm also planning to make and copy an .iso of the source drive over to another external hard-drive just in case things don't always work with the disk-to-disk cloning.

In order to solve this problem, I used CloneZilla 1.2.1-23 to clone my current Ubuntu setup (with all applications, emails, and other data) over to a second drive (target).

First of all, the size of the target drive matters -- it cannot be smaller than the source drive. That's pretty obvious, but I was hoping there would be some way for CloneZilla to see that only a portion of the source drive was being used and copy just that data over to the target drive, resizing partitions as needed.

No big deal. I just had to play around with the partitions on both drives to make sure that the source drive was smaller than the target drive. There are plenty of tools that allow you to edit the partitions on any of your attached hard disks, but it's not very safe to edit the partition used to boot into Ubuntu since the source drive is mounted.

Therefore, I created a new bootable CD off the latest System Rescue CD ISO (http://www.sysresccd.org) in order to run gparted from outside Ubuntu. This CD is a life saver and has a lot of great tools. Resizing the partitions took about 10 minutes and once that was done, the CloneZilla part was a breeze.

Next time I run through the CloneZilla process I'll write the exact instructions down. For now, I'll just say that I walked through the CloneZilla wizard and gave logical answers to questions, answered "yes" to all of the paranoid "are you sure?" questions, and after about 20 minutes, the target drive was cloned and bootable (CloneZilla also installs GRUB on the new drive).