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.
How to Clone Hard Drive to Smaller Drive
Replacing A Disk With A Smaller One Using Clonezilla Live
Clonezilla – The Free and Open Source Software for Disk Imaging and Cloning
Gnome Partition Editor