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?
-
You can easily make a full disc image of your Ubuntu install using Clonezilla as described in this answer. You can then install/restore that image onto your SSD. – larouxn Aug 20 '14 at 16:12
-
How would I then make Ubuntu pick up my home directory off the Hard disk rather than the ssd? – John Rose Aug 20 '14 at 17:24
-
Do you have a separate home partition? – larouxn Aug 20 '14 at 17:45
-
Also, the sdd is much smaller than the hard disk i.e. it will containn the system but not the data (on /home). – John Rose Aug 20 '14 at 17:46
-
Well, will your Ubuntu install fit on the SSD by itself? (without Home) – larouxn Aug 20 '14 at 17:48
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/sdX
should 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-directory
option, have a look at the grub-install manpage).Update the configuration
You need to update the UUID in
/etc/fstab
for/
. 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/fstab
and 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 1
But 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_username
with the name of your user's home directory) and some options (pay attention torelatime,acl
and2
at the end):# Mountpoint for home or user partition UUID=063a996a-0303-42b2-b719-af920fd105fa /home/$your_username ext4 relatime,acl 0 2
Save 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/home
infstab
, you can usesudo rsync -av
again 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 0
Additionally 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 -u
after 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.cfg
on the new ESP. Replacing the UUID with the UUID of the new root partition should be sufficient, if not change thehd0,gpt2
part 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-grub
here 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/sdX
is the device name of the new harddrive,Y
the partition number.

- 28,763
-
Thanks for the info: very clear & extensive. I shall now order the ssd, drive bay mounting bracket, data & power cables. – John Rose Aug 21 '14 at 07:12
-
I don't understand the use of /media/$mountpoint_of_old_drive/ in step 1. If booted from the old drive, then the old drive will not have a mountpoint for itself. Therefore, the command should be: sudo rsync -av --exclude=/home/* / /media/$mountpoint_of_new_drive/ Am I correct? – John Rose Aug 22 '14 at 07:55
-
@JohnRose The instructions should be followed while booting from live media. – LiveWireBT Aug 22 '14 at 07:58
-
Apologies: I didn't notice the "booting from live media". I've created a GPT Partition Table on the SSD using gparted. Should I create a partition and if so what type? I'm using EFI in the BIOS. On my HDD (using GPT & EFI), there are 3 partitions (using GPT): fat32 of size 512MiB with boot set, ext4 of size 690.24GiB, linux-swap of size 7.90GiB. – John Rose Aug 22 '14 at 15:11
-
I've created partitions on the SDD as per the HDD (but with the ext4 one smaller as it doesn't contain /home) i.e fat32, linux-swap & ext4, and done step 1 (rysnc) OK. See next comment. – John Rose Aug 22 '14 at 17:17
-
However, on step 2, I get: ubuntu@ubuntu:~$ sudo grub-install --boot-directory /media/ubuntu/0d248ee7-6e51-4cfd-aa7e-f1963792d493/boot /dev/sdb1 Installing for i386-pc platform. grub-install: warning: File system `fat' doesn't support embedding. grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged.. grub-install: error: will not proceed with blocklists.
PS I first tried sdb (rather than sdb1) in the above, but that also failed. Help please!
– John Rose Aug 22 '14 at 17:17 -
I created Ubuntu Trusty 64 on my USB stick using "Startup Disk Creator" - which AFAIK didn't give me any option to create as UEFI install. It works fine for booting: the BIOS shows it as UEFI:USB Hard Drive. There doesn't seem to be any option in the BIOS to boot in UEFI mode only. So I don't know what to do. – John Rose Aug 22 '14 at 18:10
-
I think that the boot is UEFI as: ubuntu@ubuntu:~$ [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD" EFI boot on HDD – John Rose Aug 22 '14 at 19:42
-
@JohnRose Hmm, something always makes me look as if I don't test my stuff (update: it turns out I did not test this particular thing from live media facepalm). Anyways, there is another solution to this, see the new troubleshooting section. (Or try grub-install from the existing UEFI installation.) – LiveWireBT Aug 22 '14 at 20:51
-
I did forget to run sudo apt-get install grub-efi-amd64. I did copy the content of my root (/) partition including /boot (but excluding /home). I've also set the Label of the first SDD partition to EFI using gparted. On grub-install: "error: cannot find EFI directory". I haven't copied the content of my ESP. How do I do that? – John Rose Aug 23 '14 at 09:02
-
@JohnRose It's just a simple file copy. :)
sudo rsync -av /boot/efi/ $mountpoint_to_new_esp
should work when you have booted from the old installation. Grub-install should besudo grub-install --efi-directory /media/$mountpoint_of_new_esp --boot-directory /media/$mountpoint_of_new_drive/boot /dev/sdX
– LiveWireBT Aug 23 '14 at 09:18 -
One question: given that there are 3 partitions in both the HDD & the SDD, I don't understand the use of $mountpoint_of_new_drive. I have this idea that one mounts a partition to a mount point not a whole drive. When I tried to mount the drive, I got a message saying that it's already mounted but mount does not show it as mounted. – John Rose Aug 23 '14 at 14:50
-
@JohnRose You are correct, one can only mount partitions. I took
$mountpoint_of_new_drive
from earlier, which should actually have been$mountpoint_of_new_rootpartition
to be correct. – LiveWireBT Aug 23 '14 at 14:55 -
I was not able to boot from the SSD even after changing the BIOS boot order. Looking at my existing Ubuntu install (i.e. on my HDD), the mount point for the first (i.e. vfat) partition is /boot/efi & the mount point for the third partition (i.e. ext4) is / with the linux-swap partition being the second. Please see next comment. – John Rose Aug 24 '14 at 11:02
-
Looking at /boot/efi (on HDD), it contains directory EFI which contains directory ubuntu which contains 4 files: grub.cfg grubx64.efi MokManager.efi shimx64.efi. Am I correct in stating that grub-install just creates these files & doesn't touch anything else on my HDD? The reason that I ask is that I don't want to change any system files on my HDD (ideally never - as I then have a fallback in case of SDD failure). – John Rose Aug 24 '14 at 11:03
-
-
-
I have had Ubuntu on SSD & my /home on HDD running OK for about a year. I used the method above as modified by the above comments. – John Rose Sep 25 '15 at 10:57
-
Without creating a new home partition, I just mounted the old HDD on an
/hdd
directory in the new SSD, and then used a bind mount to have the "old"/hdd/home
accessible under/home
. – Jellby Jul 11 '20 at 10:19