3

I have a machine where due to its history the grub partition sits between two large ext4 partitions, all seen in the picture below. I would like to merge the two partitions which currently sandwich the grub partition (as seen below, one of them is already empty and ready to be re-claimed). So that I'll effectively have one big continuous ext4 partition.

How would I most elegantly and safely move the grub partition and merge the two large partitions which currently surround it?

enter image description here

I found that GParted doesn't offer a way to move the grub partition, at least not when the system is live, and later I found that using GParted from a live USB stick won't allow moving the grub partition either, even though there is a very large unallocated partition (see in the picture again). So I am wondering how to safely and possibly also simply accomplish this in order to better utilize my drive.


Some additional technical details which hopefully do not matter

In case this ties in, this machine should always boot from one partition, all other detectable OS partitions other than its /dev/sda5 are either invalid or completely obsolete. I'd like to move the grub2 partition so that I then can make /dev/sda5, my only boot partition, larger.

And in case it matters, /dev/sda2 is still shown as a boot option in my grub menu even though I've already un-allocated that partition altogether (it's that empty partition right before the grub2 partition in the picture).

Thanks!!

4
  • 1
    We don't know if you use BIOS-boot (for that this partition is needed) or UEFI-boot (for that the first partition sda1 is needed). If you use UEFI-boot, the BIOS-boot-partition is not needed and could be simply deleted. If you really use BIOS-boot and move the BIOS-boot-partition you will have to reinstall Grub (boot-loader).
    – mook765
    Mar 27, 2020 at 10:32
  • Would UEFI simply boot into the Ubuntu partition without any necessary setup if grub is removed?
    – matanox
    Mar 27, 2020 at 13:45
  • You can confirm how you boot: Check UEFI boot mode [ -d /sys/firmware/efi ] && echo EFI || echo Legacy Also if fstab mounts the ESP - efi system partition. There are two versions of grub. One for BIOS grub-pc that uses the bios_grub on gpt drives and one for 64 bit PC UEFI boot grub-efi-amd64.
    – oldfred
    Mar 27, 2020 at 14:15
  • This question is still open, and additional detail has been added
    – matanox
    Apr 4, 2020 at 17:44

1 Answer 1

0

Boot from a live USB disk. Using gparted you should then be able to simply move the grub partition. Just make sure the disk isn't mounted. And of course: Make sure you have a backup before doing that.

9
  • Will I be able to then also merge the free space that would become contiguous to my ext4 parition after moving the grub partition like so?
    – matanox
    Mar 27, 2020 at 10:17
  • By live USB disk I assume a USB stick where Ubuntu can be booted from
    – matanox
    Mar 27, 2020 at 10:18
  • 1
    Yes, that shouldn't pose any problem. Just right-click the grub partition, select "change size/move" and move it to the left. Then you can do the same thing to the ext4 partition. Move it to the left and then adjust the size to include the unallocated space.
    – Béné
    Mar 27, 2020 at 10:22
  • 1
    Yes, exactly. You can use an Ubuntu live USB stick. Check out this tutorial: ubuntu.com/tutorials/…
    – Béné
    Mar 27, 2020 at 10:24
  • Awesome. I thought but wanted some advice before going that route. Hope this answer helps other people as well in the future!
    – matanox
    Mar 27, 2020 at 10:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .