Ubuntu – How to expand boot partition in front of LVM partition

bootgpartedpartitioning

I have a Ubuntu server where my boot partition needs to be expanded:

GParted partition view

The server is virtual and running on VMWare. I have booted from the GParted LIVE CD (version 0.27.0) but GParted doesn't let me resize the partitions.

If I understand correctly I need to move some of the 4GB unallocated space (equal to the size I would like to expand the boot partition with) so it is located just right of the boot partition.

The yellow locks in the image appearently means that the partition /dev/sda5 is mounted, but I don't understand by who and why – since I'm booting from a LIVE CD.

Calling sudo umount /dev/sda2 or sudo umount /dev/sda5 just tells me that they aren't mounted:

Unmount LVM partitions

GParted allows me to click deactivate on /dev/sda5 but it doesn't change anything:

Right click menu with deactivate option

In the end I would like to expand /dev/sda5 to take up the remaining unallocated space, but the first step is to expand the boot partition.

How can I expand the boot partition?

Best Answer

I faced the exact same problem, came across this post, and solved it. I did the following with a 16.04.3 live CD:

  1. Used KDE Partition Manager to expand /dev/sda2 to the end of the drive

  2. Used KDE Partition Manager to move /dev/sda5 to the end of the drive

  3. Tried to use KDE Partition Manager to squeeze out the empty space on the left side of /dev/sda2, but failed. It wanted to first move /dev/sda2 to the right and then chop off an equal amount of space from the right side of /dev/sda2 but there was no room on the drive to do so.

  4. Used gparted to squeeze out the empty space on the left side of /dev/sda2.

  5. Used gparted to grow /dev/sda1 and occupy the whole space.

It worked without updating grub.

Notes:

  1. /dev/sda5 is encapsulated by /dev/sda2 so you can't move or expand /dev/sda5 without making changes on /dev/sda2 first.

  2. You may try to move /dev/sda2 directly to the right. I should have tried it before expanding /dev/sda2.

  3. I used KDE Partition Manager first because I was convinced that gparted doesn't support LV, but now I doubt it because I can activate/deactivate LV with gparted, and I will try gparted for the same operations if I have the chance in the future.

Update:

I recreated the scenario in a virtual machine and tried gparted from 16.04.3 live CD. Now I can confirm that the whole procedure can be done solely by gparted, but I can't move /dev/sda2 directly to the right.

Related Question