Cloning hard disk partition to smaller SSD on laptop [duplicate]

On my linux laptop, I currently have a 250 gb hd that has a 100gb partition but only 50 gb of it is used. I would like to change to upgrade my system to a 64 gb SSD.

I read about Clonezilla and the dd command but this apparently clones the whole partition. This would not work because the partition is 100 gb and my new SSD is only 64 gb.

I also read that I could resize the 100 gb partition to a smaller size than the 64 gb SSD but won't that destroy data that is currently on my hd partition? And if I can do this without losing data, how to I then copy it to the new 64 gb SSD? (I start a live CD version of Ubuntu, then dd the old disk to an external usb drive. After that I physically remove the old HD, put in the new SSD and dd the partition back from the USB to the new SSD. If I do that, won't I have to also create a partition to my external usb hd?)


Warning:

This answer is for old filesystems with MBR, and legacy BIOS systems. It will not work for newer systems with UEFI.

Backup! Backup!! Backup!!!

I can't overemphasize the importance of backup. Backup your data. Backup the whole partition. Do it twice.

SSDs are getting cheaper. Buy a bigger SSD, say 120GB. Use the 64GB for an extra backup.

Now let us go step by step and do what you want.

Step 1: Boot from live CD/USB

Use the try Ubuntu without installing option. Plug in the external hard drive. It has to be at least 64GB or bigger.

Step 2: Identify the disks

Open Gparted. I prefer Gparted because it is visual and let me "see" the drives and partitions. Click on the top right drop down and see the list of drives. Go through the list and identify the drives you want to work with, by their size and partition structure. You want to identify the internal hard drive you want to clone from as well as the external hard drive you want to copy to.

enter image description here

Step 3: Shrink

Make sure you have selected the internal disk you want to transfer.

Select the 100GB partition you want to copy.

Drag the right edge of the partition leftward to resize/move it as far as it would go.

If it does not go below 64GB, you will need a bigger SSD. If it goes below 64GB, don't worry, you will be able to expand it later once it is copied into the SSD.

Press the "Apply" button in Gparted and wait.

If all goes well go to the next step. If you get an error, stop!

enter image description here

Step 4: Copy partition

Select the partition you just shrunk and from the menu select copy.

Select the external hard drive and paste the partition there. It is best if the external hard drive does not have any partitions and or data.

You don't have to create a new partition beforehand in the external hard disk to copy the partition. You will need unformatted / unallocated space in the disk

Apply to actually do the work.

enter image description here

If the external hard drive is bigger than 100GB, you can switch steps 3 and 4. That is copy first and shrink later. This will take longer, but has the benefit of keeping your original partition unchanged.

Step 5: Switch HDD with SSD

I hope you know how to do this.

Step 6: Boot live CD/USB again

Plug the external hard drive back once booted. Open Gparted again. Verify the identity of the SSD and the external hard drive in Gparted.

Step 7: Copy from the external hard drive to SSD

Select the partition in the external hard drive and from the menu select copy.

Assuming it is a new SSD, you may need to create the MBR (msdos) in it before you can paste the partition.

enter image description here

Select the SSD and paste the partition there.

enter image description here

Apply to actually do the work. Until you press Apply it will look something like this:

enter image description here

Step 8: Reinstall Grub2

Since part of GRUB resides in the MBR, you have to reinstall GRUB in the SSD before you can boot from it.

  1. While still booted from the Live USB, open a terminal, either by searching for it or pressing Ctrl + Alt + T.

  2. From the terminal, run

    sudo grub-install /dev/sdX
    
  • Note: X is the letter assigned to your new SSD.

See How to reinstall grub by ubuntu 14.04 live CD? for details.

Step 9: Reboot from SSD and enjoy!

If all goes well it should work

Hope this helps