0

I would like to move my hard drive Ubuntu installation to a new SSD.

The source disk has 5 partitions,

sdc1 - EFI
sdc2 - NTFS
sdc3 - Ubuntu root
sdc4 - Swap
sdc5 - Ubuntu home

I would like to move partition 1, 3, 4 and 5 to the SSD. I can resize them, and they will then fit on the SSD.

I am looking at this answer here,

How can I repair grub? (How to get Ubuntu back after installing Windows?)

It's saying that I can copy a whole drive, then mount it and install grub to fix the boot loader.

Will the same work if I copy separate partitions rather than a whole drive? I don't want to include the NTFS partition.

I think I would be doing something like this on the new SSD, set it up as GPT, copy the four partitions separately, then boot into a ubuntu live installation, mount the new installation, chroot, update-grub.

My questions are, will this work, and do I need to copy over the EFI partition? Does ubuntu add the EFI parition, or would my windows installation have added that?

I had a look at /etc/fstab and I think it has some of the answers,

# / was on /dev/sdd3 during installation
UUID=1e2e2c4b-020b-41c6-b30a-21173388e4a7 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sdc2 during installation
UUID=F03B-8C98  /boot/efi       vfat    umask=0077      0       1
# /home was on /dev/sdd5 during installation
UUID=9941c627-fce7-4a0c-821d-f140f2a7fa43 /home           ext4    defaults        0       2
# swap was on /dev/sdd4 during installation
UUID=c0704a89-c408-4d6d-bd08-a42127dba046 none            swap    sw              0       0

The EFI partition mentioned in there is not the EFI on that drive, it is the EFI partition from a different drive which is my windows 10 drive. Should I copy that one instead or does it not matter?

peter
  • 191
  • 2
    It may work, but a better question would be why this is worth the effort? It is pretty easy and quick to install Ubuntu, and copying just your partition 5 to a new partition on the SSD should be trivial. – Charles Green Apr 03 '21 at 04:10
  • You only need one EFI on the whole system but you will not be able to boot if you ever remove the disk where it resides. It’s likely Windows created the EFI that is working now and Ubuntu used it when Ubuntu was installed. Where the EFI came from on the disk you want to copy is unknown. Does it boot if you alter your boot order? That disk is currently sdc but at one time it was sdd so there has clearly been changes. You can only have one EFI per disk. There is some advantage in having one on the Windows disk as well as the one on the Ubuntu disk. If either disk fails you can boot the other. – PonJar Apr 03 '21 at 08:06
  • 1
    That depends on how you 'copy' those partitions. A clear way is you just make four blank partitions on SSD, do rsync instead of copy of all data respectively. You replace the UUIDs of filesystem mountpoints listed in the old /etc/fstab. Then you do mount, and chroot, do grub-install, update-initramfs and update-grub. You are done. – funicorn Apr 03 '21 at 11:09
  • @funicorn "do rsync instead of cp of all data respectively" — why would you prefer rsync, or, in other words, what's the point, when there is nothing in the target to diff against? – Levente Apr 05 '21 at 02:15
  • Because rsync is more prepared for unpredicatable interruption. – funicorn Apr 05 '21 at 03:07

2 Answers2

2

Yes, as suggested by Charles Green, this could have worked, but what's the point.

I did go for a fresh install on the SSD and got everything I needed back up and running in a couple of hours. It has been running very well ever since, good suggestion.

peter
  • 191
0

I just did this.

I booted up using the rescue version of Ubuntu 22.04. (In this case, my rescue version was the Desktop install version). You really don't need a rescue version. But on your boot USB stick, you may be required to install gparted. Boot up using the USB stick. Don't install just try it out.

Open a Terminal. Type sudo su Type apt-get install gparted.

Run gparted. Create a partition. Copy the desired partition to the new partition. Copy then paste.

Reboot into your original Desktop.

Open a Terminal

Switch to the root user. sudo or su Type update-grub.

When it's done, reboot, use the grub boot menu, and choose the new partition.

  • The Try Ubuntu option of the Ubuntu live USB enables the user to launch GParted which is installed by default. – karel Jan 31 '23 at 09:11