It’s just yulistic!

Replace HDD or SSD without the re-installation of Ubuntu

· by yulistic · Read in about 2 min · (347 Words)
linux Ubuntu copy partition partition migration


I tried to replace the HDD in my Ubuntu PC with a new SSD for the performance improvement.


[1] Partition copy and paste with GParted in the Ubuntu Live USB
[2] Change UUID of a partition


Please backup your data before starting the following processes.

It is assumed that you have already installed a new storage HW into your PC. Also, Ubuntu live USB is required.

1. Boot with the Ubuntu live USB.

2. Start gparted which is a partition editor program.

3. Select the original device in the top right corner.
Select original device

4. Copy the partition that you want to migrate. If the original partition is larger than the new partition, shrink its size by resizing the partition.

5. Select the target device and paste the copied partition. If the device is in the first use, you need to create a new partition table before the paste. I chose msdos that was identical to original partition’s. I checked it in the /boot/grub/grub.cfg file. Also, you can resize the pasted partition as you want.

6. If your original partition has a boot flag, which means it was a boot partition, you need to set the boot flag of the pasted partition.

7. Apply all the changes.

8. Re-install GRUB. If your partition is a boot partition. Check the new device name and the new partition name. For example, in my case, the new device(SSD) name was /dev/sdc and the partition name was /dev/sdc1. Run the following commands in a terminal.

sudo mount /dev/sdc1 /mnt
sudo grub-install --root-directory=/mnt /dev/sdc
sudo umount /mnt

9. Change the UUID of the original partition with the following command. The random parameter will generate a new random UUID number.
(This process is required because gparted copies all the data in a partition including UUID. You can find UUID of each partition with the sudo blkid command. The same UUID in two different partitions will confuse your operating system.)

sudo tune2fs /dev/sdc1 -U random

10. Reboot with the new partition. You might need to change the boot priority option in the BIOS.