I recommend against using dd
. It just does a dumb sector by sector copy, which means it will fail if the destination partition is smaller, and wastes a lot of time copying free space, and if the destination partition is larger, the additional space will not be available until you run resize2fs
to expand the filesystem.
It is best to do this from a live CD because if you copy files while they are being modified, you will end up with corrupt results.
Format the ssd and get both the new ssd partition and the original root partition mounted, then just run sudo cp -ax /media/old-partition/* /media/new-partition
, where old-partition and new-partition are replaced with their actual mount points. That will copy every file over, preserving ownership, permissions, and timestamps.
Then run sudo grub-install --root-directory=/media/new-partition /dev/SSD_DEVICE
, after substituting correct values for new-partition and SSD_DEVICE. That will install grub, making the disk bootable.
Once you reboot (making sure your bios is configured to boot from the ssd instead of the old drive ), make sure that you are running from the ssd and not from the old drive by checking the output of df
and/or mount
, and you should be good to blow away the old partition.
Oh, and you will want to edit the /etc/fstab
file on the new partition after copying and updating the UUID of the root partition to match the UUID of the new SSD partition instead of the old one. You can find that UUID by running sudo blkid
.
Edit: added /* in copy above, but needed edit to be more than 6 characters. Now it's 101 characters!
To my experience a formula describing partition sizes in % are no use here. Absolute values I would recommend are
- 4 GB Swap
- 10-15 GB for OS depending on how much software you want to install
- the rest for the home partition.
It should be sufficient for beginner to experienced user, I don't know what exact demands real power users have.
Best Answer
Clonezilla may be useful for cloning your hard disk, even for those situations on which you need to do it with different size disks as mentioned here: http://www.tuxradar.com/content/how-clone-hard-drives-clonezilla
There is documentation about moving to a larger disk as mentioned here but I am not sure that you can do it the opposite (cloning to a smaller disk).
However, it's worth to try. Clonezilla offers several Live CD's and bootable USB images and there is also documented that you can resize the free space on the disk after the copy, in which case the suggestion by @maniat1k to use gparted is also a good idea.
If you use clonezilla, I would appreciate if you drop comments with your experiences over here in order to have well documented how does this work for future reference.
Thank you a lot and Good luck!