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?
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).
sda1is 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).
[ -d /sys/firmware/efi ] && echo EFI || echo LegacyAlso 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.