SSD drives have finally become affordable and more reliable than they used to be. Partly this was sure helped by the price boost of the traditional hard-disks manufactured in Thailand (I think everybody still reminds the floods from the summer of 2011). The competition helped the development of innovative solutions and after 4 years since their mass-consumption breakthrough they have managed to become a standard on ultrabooks and premium laptops.
Because the price / GB of the classic mechanical hard-disk was so low (as low as US$0.05 per GB for 3.5 inch drives and US$0.10 per GB for 2.5 inch drives), producers started to offer larger drives for the same money. Unfortunately SSD technologies cannot and probably will not evolve the same way due to memory degradations once the chip size decreases. In particular this led to higher prices for the same disk size, making SSDs more attractive for boot / OS drives instead of plain storage ones.
Migrating a current OS installation usually has to take into consideration that the SSD destination disk might not be able to fully accommodate the previously stored data. The following paragraphs will describe what solutions can be employed in order to successfully migrate an Ubuntu installation (or any other Linux distribution) to a SSD drive.
Depending on the available storage space of the SSD, there are two available solutions:
the destination drive is just as big as the source drive, or larger –
the destination drive is smaller than the source drive –
Tools needed for both solutions:
an Ubuntu live CD / live USB stick from which to boot and perform the migration;
at least two SATA drives, one for the source and one for the destination disk;
at least two SATA data cables and two SATA power cables if you’re using a desktop machine to perform the migration, or a SATA to USB adaptor if you’re using a laptop;
a Philips screwdriver to mount / un-mount the hard drives and possibly the 3.5” adaptor.
It’s time to connect the hard drives to your machine.
1. Same size or larger SSD
If the SSD you have installed on your machine is the same size or larger than your current mechanical drive it means that you’re rich. Furthermore, the work you have to do to migrate your system to the new drive does not require too much effort.
ddrescue is a great tool for restoring information from failing drives but it can also be used to perform bitwise clones.
To start migrating your system from one drive to the other, perform the following steps:
boot your machine using the live CD / USB stick;
enable the “universe” repositories on Ubuntu and install
sudo apt-get update && sudo apt-get install gddrescue
gddrescueto clone your drive:
sudo ddrescue -v --force /dev/sda /dev/sdb
/dev/sdais your source drive and
/dev/sdbis your destination drive
have patience; depending on your disk size and your machine’s performance this might take a while.
At the end you should be able to seamlessly replace the old spinning drive with the SSD and just enjoy the snappiness of your system.
2. Smaller SSD - the usual compromise
Trying to clone a larger disk to a smaller one using
ddrescue is not trivial, even if the total used storage space would be less than the SSD’s storage capacity. In this case three software tools of the *nix Swiss Army knife have to be used:
gparted– for setting out the partitioning layout;
rsync– for selectively synchronising the needed data (you can easily decide what to exclude using patterns);
boot-repair– to fix your Grub2 setup.
Boot your system using your live Ubuntu image. Using
gparted (it is included on the live image) create the desired partitions on your SSD. Currently only 2 Linux file systems properly support SSDs (making use of native TRIM):
ext4. Out of these two, only
ext4 is considered mature enough to be used on production-ready systems, due to its mass-adoption in the Linux world.
In order to align your partitions with the drive’s sectors (for optimal performance and longevity) make sure to leave the first MiB of storage unallocated and to align your partitions to MiB, not cylinders. This is fairly intuitive with
Remember to add the
boot flag to the partition where your
/boot folder will be stored.
Once your SSD drive is partitioned, mount the source and destination partitions. This can easily be done from Nautilus, the default file browser from Ubuntu. Just open the home folder and on the left sidebar you can see the unmounted file systems. Click on them to let the system mount them automatically. I strongly recommend to mount them two by two (1 source, 1 destination) in order to avoid any complications. Using
rsync selectively sync your partitions:
sudo rsync -a -v --exclude "excluded_folder_name_or_pattern" /media/<source_uuid>/ /media/<destination_uuid>
rsync will not be able to handle
grub, thus you will not be able to boot your system. Restoring
grub is very straight-forward. Again you will need the live CD / live USB stick to boot up your machine. After Ubuntu is up and running from the installation medium, you just need to install and use Boot-Repair. A very good guide is available here.
Specific mount options for SSD
Because of the way SSD drives work, some mount options need to be specified in your
discard– this enables TRIM;
noatime– this disables pointless writes to disk to store the last accessed time for a read file
fstab file should look more or less like this:
1 2 3 4 5 6 7 8 9 10
Migrating from your slow mechanical hard drive was easy. I am pretty sure that if you have not used a SSD drive until now you will definitely question yourself why it took you so long to switch - I know I do. Sometimes we fail to remember that the hard-disk is still the slowest component in a computing system. A SSD might be the solution to speed up your machine instead of buying the newest and coolest CPU and it’s definitely cheaper as long as you can accommodate with less storage space for the drive that should store your OS and applications (and maybe your media workspace).