1

The layout of my disk currently is [swap, /, /boot/efi, home].

I want to move /boot/efi to the left, delete the swap as I don't think I need it and give some space from home to /. What steps would I take to do this?

I created a live usb and used gparted but it said that if I move the partition containing boot then the system will no longer be bootable and I have made that mistake in the past.

It's a work laptop so it will have a lot of configuration and keys saved all over / so I don't want to start again with a fresh install, also my internet is painfully slow and would take about a day to get running again.

I couldn't find any definitive way to do it online, I've read about changing the UUID in fstab after moving the partition and reinstalling grub 2 but there was never an example specific to my case. I also don't have a hard disk large enough to do a full system backup, but if I deleted home partition that would cover /.

  • 1
    Editing partitions is always risky, and unless it is absolutely necessary to do it now, I suggest that you wait until you have a drive where you can store a full backup. – sudodus Aug 31 '22 at 10:07
  • You do not need full system backup as you can just reinstall Ubuntu. But you must have backup of your data usually most in /home, your settings which are in /home's hidden files, and a list of installed apps. If you changed any system setting those normally are in /etc. I edit grub, but just copy to /home so in my backup. You must also have current working live installer to make repairs. I would do it in steps. Is drive MBR or gpt? Post details: sudo fdisk -lu – oldfred Aug 31 '22 at 13:48

1 Answers1

1

As long as you have a good backup of your personal data, you are covered.

In principle, reinstalling grub after the partitioning has changed should make the system bootable again.

swap can be deleted - I still advise to keep a relatively modest swap file around: this still is a safeguard when at some moment memory is lacking.

The EFI partition could be deleted and recreated in the front of the disk.

Then the system partition could be moved more to the front, to follow the EFI partition. Note that this will take quite some time, and there is a chance that it will fail. If it doesn't, you are good and can expand the /home partition to fill the remaining space, or enlarge it somewhat then create a separate /home if you prefer (I personally don't (anymore)).

From a live system, you will then need to open the fstab file on the root partition on your disk (not the fstab from the live session!). Take note of the UUIDs of EFI, root partition and eventually /home (sudo blkid), and update these in the fstab file.

Then you should be able to reinstall grub from a live session, after chrooting into your root partition on your disk.

If there is a failure along the way, reinstalling new, placing your data back, and reconfiguring your system may (eventually) take a little longer (be warned again that the move of your partition may take a long time), but it is not the end of the world, and it is technically by far the easiest approach.

vanadium
  • 88,010