“Cloning” a hard drive to a smaller SSD

I recently switched out a 160 GB hard drive on an old laptop computer for a 120 GB solid state drive (SSD). The process should have been easy – just make a disk image of the hard drive, and restore it to the SSD. However, free disk imaging programs (especially Windows-based products) typically don’t allow this, and offer to let you purchase a “pro” version that provides such capability as an additional feature. Now, there really isn’t a good reason for this since, in principle, there is no problem in copying a number of disk partitions from a hard drive, with lots of unused space, to a smaller drive onto which the said partitions will fit. So, it’s really just a case of finding the (free) software that will do the job.

In the past, I have used partimage to backup disk partitions; however, this is an old program and doesn’t support the ext4 file system. Since my current installation of Ubuntu uses ext4, partimage was a non-starter for my present purposes. However, Clonezilla is a similar disk imaging program, which does support ext4, and so I opted to give this software a try.

Documentation available on the web indicated that the task at hand was indeed possible using a combination of Clonezilla and Gparted (the Gnome Partition Editor). I used bootable versions of both these programs, with the full process involving the following steps.

(1) The first trick is to use Gparted to resize the partitions on the hard drive, shrinking each partition so as to reduce the amount of unused space it contains. Obviously, the partitions must be sized such that the total space required for all the partitions is less than the capacity of the SSD.

(2) One then runs Clonezilla and makes a copy of the individual hard disk partitions (using the saveparts option), storing these temporarily on an external USB drive. Note that it is necessary to save the partitions (saveparts) rather than making an image of the entire disk(savedisk).

(3) With the SSD installed in the target machine, the second trick is to use the partition manager once more to create the desired partition structure on the SSD. I took the opportunity to mark /dev/sda1 (the boot partition on the original hard disk) as the boot partition (Gparted – Partition – Manage Flags) on the SSD, hoping that this would allow the machine to boot at the end of the exercise (more on this later).

(4) Clonezilla is then used to restore the saved partitions (using restoreparts) onto the SSD.

(5) If necessary, Gparted can be run once more to resize the SSD partitions as desired in order to completely fill the available disk space.

While the process, as noted above, is relatively simple, Clonezilla isn’t for the faint of heart. I have never seen so many error messages streaming by when Linux software is loading. However, despite the multiple apparent failures – “…critical target error”, “Failed to load file”, “File doesn’t exist”, “Cannot open file for reading” – the program does actually load and run! The DOS-like menu system, with its many options, is similarly daunting, but the detailed instructions, complete with screenshots, from geekyprojects.com provide an excellent how-to guide.

The final thing to note is that Clonezilla does not copy any linux-swap partitions so that any required swap partition must be specifically created (using Gparted) on the smaller drive.

Once the transfer process was complete, the machine did indeed boot into the grub menu, and the Linux-boot option proved to be functional. Alas, the same could not be said for the dual-boot option into Windows. This “other” operating system seemed to take umbrage to its partitions being moved around and simply refused to boot.

The solution to the latter problem proved to be a two-stage process. Firstly, a Windows Recovery Disk (bootable CD) was used to “Fix startup options”. This did indeed “fix” the startup options. The machine would now boot into Windows – but only into Windows! – the grub menu had disappeared. So, onto the second stage of the recovery operation where a bootable Rescatux disk (actually a bootable USB drive) was then used to restore the grub menu (Rescatux – Grub (+) – Restore GRUB). Now, finally, all the boot options were functional from the SSD.

The good news, after this somewhat convoluted series of operations, is that my five-year-old laptop now boots into Ubuntu in 28 seconds (previously 44 s) and into the Windows desktop in 43 seconds (previously 1 m 25 s). Loading programs and data files is similarly more speedy. So, for my purposes, the process turned out to be a very worthwhile exercise.

References:

How to Clone Hard Drive to Smaller Drive
http://geekyprojects.com/storage/how-to-clone-hard-drive-to-smaller-drive/

Replacing A Disk With A Smaller One Using Clonezilla Live
http://preview.tinyurl.com/cnjm6yg

Clonezilla – The Free and Open Source Software for Disk Imaging and Cloning
http://clonezilla.org/

Gnome Partition Editor
http://gparted.sourceforge.net/

Rescatux
http://www.supergrubdisk.org/rescatux/

Advertisements
This entry was posted in Applications and tagged , . Bookmark the permalink.

2 Responses to “Cloning” a hard drive to a smaller SSD

  1. Ovid says:

    Thank you for your informative posts.

    Incidentally I had a similar problem recently an I want to make a few comments.

    One one occasion I had to move only Windows partitions from a smaller HDD to a bigger SDD. I used Acronis 2011. As I had only ntfs partitions on the HDD, I used the clone function, which copies and resizes all the partitions. Then I used GParted to create ext4 partitions and installed Ubuntu.

    On the second occasion I had to move a Windows partition and two Linux partitions from bigger HDDs to a smaller SDD. I also used GParted to partition the SDD first. I still used Acronis for the ntfs partition, but this time I made a copy of the HDD partition and then restored it on the SDD. One advantage of Acronis is that it can restore to a smaller partition, provided that the data can fit. I used clonezilla for the ext4 partitions. Unlike for Acronis, the destination partitions have to be at least the same size as the source ones. I did not encounter any errors this way.

    On both occasions I had to leave approx 10% of the SDD unformatted, as recommended by the manufacturer. I would also recommend the following article for tweaking Ubuntu for better SSD performance: http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm

  2. Franck says:

    Thank you for this great tutorial, i have my favorite Lubuntu on my SSD now .
    I resize partitions on the old disk setup exactly the SSD in the same order and Clonezilla restore whithout any warnig, just a grub failure after the reboot, and all in bigginer mode .
    The issue for grub is in the faq gparted “13: GRUB fails to boot. How can I fix this?” less than five minutes of work .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s