6

This has been asked here, Why I'm seeing a lock besides the partition I'm trying to modify with gparted?, but I'm having problems.

These two partitions both have ext4 as their file system. They are both unmounted. Swap space is swapped off:both

I want to extend sda1 with sda3. I have no data on sda3

However, when I click resize/move on sda1 I get this:

sda1

It's as big as it can go!

It's the same story if sda3 is empty unallocated space:

unallocated

sda1 is as big as it can be. How do I extend it into the unallocated space?

Worth mentioning that the screen shots are from a liveCD containing GParted's iso.

I gather I need to move unallocated space next to the drive that needs to be extended. I cannot click and drag sda2 containing swap space an inch.

This liveCD shouldn't be using it but it's the best answer I've had:

sda5

I can extend the swap space no problem. What does this mean?

extended swap

  • How do I move them? Click and drag? That doesn't work... – Starkers Aug 12 '14 at 17:03
  • I've downloaded the latest GParted and yet this isn't working. I can click and drag the sliders, but I cannot click sda2 in the bar and move it at all! Why do you think this is? Is there a shortcut I can use instead? – Starkers Aug 12 '14 at 17:06
  • See askubuntu.com/questions/326518/… – user68186 Aug 12 '14 at 17:11
  • You might wish to look at Moving Space Between Partitions for an example on how to migrate unused space when primary, extended, and logical partitions are involved. – Curtis Gedak Aug 12 '14 at 20:52
  • Never thought I'd say this...but this is so much easier in Windows! – Starkers Aug 12 '14 at 20:54
10

Step 0: Backup your data

Make sure you have up to date and good backup of all your personal files. The backup must be outside your computer. If you haven't backed up your data, stop now and make backup.

Step 1: Boot from a LiveCD/DVD/USB

You have done this. I am writing it for anyone who may read this later. This is important, as you can't change a tire of a car while you are driving it.

Step 2: Disable Swap

Open a terminal by pressing Ctrl+Alt+T, or click on the Terminal icon of live CD desktop

sudo swapoff -a

Step 3: Delete Swap partition

Make sure the swap partition is unmounted. Right click on the Swap partition from within Gparted, and click on Unmount.

Now you should be able to delete swap partition. It is the logical partition /dev/sda5 inside the extended partition /dev/sda2.

Step 4: Delete Extended Partition /dev/sda2

The extended partition can't be deleted until the logical partition inside it is deleted. We did that in step 3. Now we can delete /dev/sda2.

Step 5: Delete /dev/sda3

You can delete this partition as it has no data. Then you will use most of this space to resize the /dev/sda1.

Step 6: Resize sda1

Use Gparted to expand /dev/sda1. Leave 8GB space (or less if you want) at the end to recreate the swap partition.

Step 7: Create a new swap partition

You can choose to create a primary partition (new /dev/sda2) for swap. Since you are going to have only two partitions in this drive, there is no need for an extended partition.

Step 8: Find the new UUID of the two partitions

Either

In Gparted: Right click on a partition and select "Information"

Or

In terminal enter:

sudo blkid

And write down (or copy to a text editor) the two UUIDs for sda1 (/ partition) and sda2 (swap).

Step 9: Edit /etc/fstab

Mount the main partition and navigate to /etc folder. Find the file called fstab. Copy the new UUID in their appropriate places if needed.

If there is any lines related to the old /dev/sda3, you should delete that. As that partition does not exist any more.

Hope this helps

|improve this answer|||||
  • GParted can show the UUID, if you right click a partition and choose "Information". – muru Aug 12 '14 at 17:41
  • and no data will be lost during this process? – Zhenyu Sep 13 '19 at 14:32
  • 1
    @Zhenyu I cannot guarantee that no data will be lost. Always have good and multiple backups of your data outside the computer. – user68186 Sep 13 '19 at 15:17
  • @mook765 I have revised the answer to take into account the extended partition. – user68186 Sep 15 '19 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.