Solid State Drives (SSD) are all the rage these days – and for good reason. They’re fast, silent, and have no mechanical parts to go wrong (although firmware bugs can and do bite people).
They’re also horribly expensive. For this reason many people who take the plunge buy drives that are smaller than the mechanical drives that are being replaced. This can be a problem. If you’re moving to a larger drive, Clonezilla or other imaging programs do a fine job, but moving to a smaller drive can be daunting. If you do a Google search there are articles all over the Web that will give you bits and pieces of advice. The following is a procedure that I know will work, because I just moved my installation from a 300GB hard drive to a 240GB Intel 520 SSD.
First things first – preparation
First of all, make sure that all of your data will fit on your new drive. No article in existence can explain how to fit 400GB of data onto a 200GB drive. So check out how much space you are using and start housecleaning. Remember that you want to have some free working space as well.
Second, back up your drive. I said BACK UP YOUR DRIVE! Better yet, download a copy of Clonezilla and image it. Then you can recover from even the worst screwup by restoring the image. Clonezilla, learn it, love it, live it.
Finally, your /etc/fstab file should be using UUIDs instead of device ids to identify drives. Open /etc/fstab, and if you have entries that look like this:
/dev/sda2 / ext4 defaults,errors=remount-ro 0 1
instead of this:
UUID=ec9de201-c1f1-44d1-b398-5977188d4632 / ext4 defaults,errors=remount-ro 0 1
Then start Googling until you can boot with UUIDs. Although I won’t cover the difference between device designations and UUIDs in this article except to say that the reason for using UUIDs is that the device IDs and partition numbers on the new drive may not match the old ones, so fstab could be incorrect. Once you can boot with UUIDs, we are in a position to assign new drives the same UUIDs as the old drive had, ensuring that fstab will not have to be edited.
Create and copy your partitions
For this part you will need a Linux Live CD or USB flash drive. Hopefully, you already have one handy in case of emergency. Boot from the live CD or USB flash drive. Attach the old and the new drive to the system.
Ok, here we go.
To copy partitions:
1. Partition the new drive. If you have “/boot” and “/” partitions on the old drive, create them on the new drive.
2. Format the partitions with the same file systems as the old drive partitions.
3. Boot from a live CD or USB flash drive
4. Open a terminal
5. mount the partitions from both the old and the new drives (use “sudo blkid” to see the devices and partitions).
6. For each partition, run:
sudo cp -afv source_mount_point/. destination_mount_point
So for example:
sudo cp -afv /mnt/old_drive_boot/. /mnt/new_drive_boot
7. run “sudo blkid” and make note of the UUIDs of the old drive (open text editor and copy and paste from the terminal).
8. Unmount the old drive partitions (“sudo umount MOUNT_POINT”)
9. For each partition, set the GUID to match the ones on the old partitions:
sudo tune2fs -U UUID /dev/sdXX
10. Turn off your machine, remove the old drive and boot from the Live CD/USB again.
11. Follow the next section derived from http://zeasite.com/blog
Install GRUB2 to your new drive
1. In Terminal type
sudo fdisk -l (or "parted" and "list" if you are using GPT instead of MBR)
2. Mount the / partition drive
sudo mount /dev/sdXX /mnt
(example ‘sudo mount /dev/sda11 /mnt’ ,don’t miss the spaces.)
3. Only if you have a separate boot partition:
sudo mount /dev/sdYY /mnt/boot
4. Mount the virtual filesystems:
sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys
5. To ensure that only the grub utilities from the LiveCD get executed, mount the /usr directory:
sudo mount --bind /usr/ /mnt/usr
6. Ok, now we can chroot onto the new drive.
sudo chroot /mnt
7. Ensure that there’s a /boot/grub/grub.cfg
8. Now reinstall Grub
(eg. grub-install /dev/sda – do not specify the partition number.
9. Verify the install
sudo grub-install --recheck /dev/sdX
10. Exit chroot : CTRL-D on keyboard (or “exit”)
11. Unmount virtual filesystems:
sudo umount /mnt/dev sudo umount /mnt/proc sudo umount /mnt/sys
12. If you mounted a separate /boot partition:
sudo umount /mnt/boot
13. Unmount the LiveCD’s /usr directory:
sudo umount /mnt/usr
14. Unmount last device:
sudo umount /mnt
16. After you successfully reboot, make sure that you change fstab and other files to tweak your system for your new SSD:
Enjoy your new SSD!