Move free space from end of the drive to first partition with gparted
Problem
Is is frustrating - no matter how I try, gparted won’t let me assign the empty space to the first partition:
The middle partition is blocking me from expanding /dev/sda1
. I need to move partition /dev/sda2
to the end of the drive, like so (fabricated image):
Then I will be able to expand first partition:
How to do that? I assume data from /dev/sda2
must be physically copied to end of the drive.
Solution
It is recommended that, before making any changes, you make backups of any data you do not want to lose in case anything goes wrong.
Before you start, both partitions will need to be unmounted– if you cannot unmount one of them (e.g. because it is your root partition), use a live CD with GParted (e.g. the GParted live CD or the Ubuntu live CD) and resize them that way.
-
Select the second (extended) partition, and click on Resize/Move
-
Use the right handle to extend the partition to the end of the free space, and then click on Resize/Move
-
Select the contained swap partition, and click on Resize/Move
-
Drag the partition to the end of the extended partition, and then click on Resize/Move
-
You can safely click OK on this warning message, as we are only moving a swap partition
-
Select the extended partition again and click on Resize/Move
-
Use the left handle to shrink the partition to the end of the free space, and then click on Resize/Move
-
Then, select the first partition, and click on Resize/Move
-
Use the right handle to extend the partition to the end of the free space, and then click on Resize/Move
-
Finally, click on Apply and your partitions should be reformatted