I would like to transfer my existing Ubuntu Trusty (14.04.1) system (including installed apps from PPAs) to an SSD. I want to retain my existing home directory on hard disk). What is the best method, preferably ones that doesn't involve reinstalling Ubuntu?
1 Answers
When booting from live media, this can be broken down into 3 steps:
Copying the operating system data to the new drive
Before you start, make shure that the new drive has the correct partition table. GPT is (mostly) for EFI and requires a special partition for the bootloader. Don't forget to mark the new operating system partition as bootable on MBR installs.
Using rsync from live media should be the most practical solution to copy the files:
sudo rsync -av --exclude=/home/* /media/$mountpoint_of_old_drive/ /media/$mountpoint_of_new_drive/Install the bootloader to the new drive
sudo grub-install --boot-directory /media/$mountpoint_of_new_drive/boot /dev/sdX/dev/sdXshould be changed to the actual device name of the new drive.If you have an EFI installation instead of MBR you should make sure that you booted the live media in EFI mode, ran
sudo apt-get install grub-efi-amd64, have created an EFI System Partition (ESP) on the new drive and that the ESP is mounted to/media/$mountpoint_of_new_drive/boot/efi(or use the--efi-directoryoption, have a look at the grub-install manpage).Update the configuration
You need to update the UUID in
/etc/fstabfor/. Get the UUID of the new operating system partition by executingsudo blkid /dev/sdXY, copy the UUID without quotation marks, runsudo nano /media/$mountpoint_of_new_drive/etc/fstaband replace the existing UUID in a line that looks like this:# / was on /dev/sda2 during installation UUID=a7aea81b-0e7f-4ec0-8be4-b0ec75c13fdc / ext4 errors=remount-ro 0 1But before you replace the line you may want to make a copy of it by pressing Ctrl+K and Ctrl+U. As your home is still on the old drive, the old UUID should be correct and you would just need to update the mountpoint to
/home/$your_username(replace$your_usernamewith the name of your user's home directory) and some options (pay attention torelatime,acland2at the end):# Mountpoint for home or user partition UUID=063a996a-0303-42b2-b719-af920fd105fa /home/$your_username ext4 relatime,acl 0 2Save with Ctrl+O and exit with Ctrl+X.
You should think about moving the individual home directories to a separate
home-partition (it's just a partition with user's home directories mounted as/homeinfstab, you can usesudo rsync -avagain to copy data, see How can I move my /home directory to another partition if it's already part of the / partition?), as you would have to create a new line for each user this way.If you created a new swap partition on the SSD you have to update the UUID for this too:
# SSD swap UUID=b7c315cb-cf89-463b-888a-185a1faa8250 none swap sw 0 0Additionally you need to update the UUID of the swap partition in
/media/$mountpoint_of_new_drive/etc/initramfs-tools/conf.d/resume, runsudo update-initramfs -k all -uafter booting from the new drive the first time and reboot to have hibernation working again.Remember to also update the mountpoint for the ESP in fstab too for EFI installs.
Looks complicated, but it's simple to do, just difficult and lengthy to describe in detail.
Troubleshooting
grub-install somehow fails to install with UEFI
Hint: You probably forgot to run sudo apt-get install grub-efi-amd64 when GRUB says something about i386-pc.
- You copied the content of your root (
/) partition including/boot, right? You copied the content of your ESP? Do that if you havent.
Edit
EFI/ubuntu/grub.cfgon the new ESP. Replacing the UUID with the UUID of the new root partition should be sufficient, if not change thehd0,gpt2part from this example accordingly too. This is how the content of file usually looks like:search.fs_uuid a7aea81b-0e7f-4ec0-8be4-b0ec75c13fdc root hd0,gpt2 set prefix=($root)'/boot/grub' configfile $prefix/grub.cfg
Boot from your old installation, run
sudo update-grub, os-prober should find the new installation on the other partition and add a GRUB entry.- Boot this new entry.
- You should be booting now from the SSD, run
sudo update-grubhere again to update and fix the GRUB configuration on the SSD.
- Run
efibootmgr -c -d /dev/sdX -p Y -l \EFI\ubuntu\grubx64.efi -L "Ubuntu"to add the boot loader for new/transferred installation as a new boot option to UEFI NVRAM./dev/sdXis the device name of the new harddrive,Ythe partition number.
- 29,597