Linux – Move unallocated space into extended partition to expand logical volume

gpartedlinuxpartitioning

I have a dual boot setup with Fedora and Windows. For personal reasons, I have uninstalled Windows and would like to use the freed-up space to expand my Fedora partition (which is on a logical partition inside an extended partition).

I am using GParted on Fedora to manage my partitions.disk partitions

The 66.90GiB unallocated space is where Windows used to be. I am trying to move that space into the extended partition (/dev/sda4) and eventually merge it with /dev/sda6, but GParted does not allow me move/resize the extended partition to make use of the free space. I read that

In Disk Management, unpartitioned space in primary partition area is called unallocated space, while unpartitioned space in extended partition area is named free space; unallocated can’t be used to extend to or create logical partition, and free space can’t be used to enlarge to or create primary partition.
(Source: https://www.partitionwizard.com/convertpartition/primary-partition-vs-logical-drive.html)

I'm not sure how true the above statement is, because people seem to have done it or somehow worked around the issue. I have looked at several questions on StackExchange including:

but I'm not sure if they're completely applicable here.

So my question is: how do I move the unallocated space into the extended partition to merge it with the fedora logical partition?

Any help would be appreciated!

Extra Info:

  • My computer uses MBR and not GPT, so I am only allowed 4 primary partitions, if that's relevant.
  • I can freely move/resize /dev/sda5 and /dev/sda6 around inside the extended partition, but I cannot move/resize the extended partition iteslf.

lsblk output

lsblk output

parted -l output

parted -l output

fdisk -l output
fdisk -l output

Best Answer

I just solved it, and I'll post the answer here in case someone else faces a similar problem.

I was unable to resize the partition because my swap space was still in use, so I found out I could disable it using swapoff -a.

After doing this, GParted allowed me to merge the unallocated space with the fedora logical partition. I then right clicked on the logical partition and selected the Check option.

Finally, I used the following to actually allocate the free space to the root and home partitions:

lvextend -L +20G /dev/fedora/home
lvextend -L +20G /dev/fedora/root
resize2fs /dev/fedora/home
resize2fs /dev/fedora/root