Partitions are boundaries on the hard disk. For any partition to expand, the free space needs to be next to the partition being expanded.
In your case above, the free space is not next to partition 5
that you want to expand, but between partition 6
and the previous partition (I am assuming partition 3
).
What you need to do is to move the partitions to shift the empty space between partition 4
and partition 5
, which will then allow you expand partition 5 as required (all operations to be done when booted via the live CD as you correctly did).
Before:
|1|...---p3---| free space |--p6--|--p7--|--p8--|--p4--|--p5--|
Expected state afterwards:
|1|...---p3---|--p6--|--p7--|--p8--|--p4--| free space |--p5--|
The following documentation in gparted should help you with the moving: https://gparted.org/display-doc.php%3Fname%3Dmoving-space-between-partitions
Warning Note: Partition moving is a risk-prone operation:
- It's sensitive to lost power.
- It cannot be undone.
As your free space is much larger than the partitions that need to be moved, your risk is lower, but still please run this operation when you do not risk power loss of any sort.