Can't resize Ubuntu's main partition with GParted

15,161

Indeed Moving a partition might cause your operating system to fail to boot but it shouldn't be that dangerous because Grub can be easily fixed at any time. Just make sure you don't have a power outage during the operation, and run a partition check before if you want

However, gparted is very stupid at moving partitions as it always moves the whole partition, unlike 3rd party partitioners which only move the files in the resized regions. For example if you move /dev/sda7 1GB to the right (and shrink it) gparted will move the 73GB of currently existing data while others will just move the amount equal to the 1GB resized part. Therefore you should avoid moving partitions with it

There's a simpler way in your case. Since there's a ~7GB unallocated space at the end, you can just delete you current swap partition, create a new swap at the end and resize the root partition (/dev/sda5) to fill the new gap from the deleted partition. Remember to update /etc/fstab and other config files to point to the new swap partition, and run grub-install again to update the boot loader

However you should generally avoid putting frequently accessed data (like swap, /tmp or /var like fpmurphy suggested) at the end of an HDD, because it's the slowest portion in a rotational disk

That said, you shouldn't even have such a huge swap at the beginning. I'm pretty sure your system will crawl to death by the time it uses just ~1-2GB of swap. You'd be better with zram or zswap with a small backup 1-2GB swap partition. Once enabling zram you can just use the unallocated portion as swap which will be rarely touched anyway


If 7GB more space is still not enough, you'll have to move some partition. Because of gparted's stupidity, you should shrink /dev/sda2 then resize /dev/sda4 (the container for the root partition) and then the root partition to minimize the amount of data movement. If other partitioning tools are allowed then it'll be better to

  • move /dev/sda3 to the right
  • then resize /dev/sda4 (the extended partition) to fill the gap
  • resize (and possibly shrink) /dev/sda7
  • move and resize /dev/sda6 (swap)
  • resize /dev/sda5 (root)

Now you'll have more space to breathe. You can also remove the swap partition and use a swap file (in addition to zram)

Share:
15,161

Related videos on Youtube

Machinerium
Author by

Machinerium

Updated on September 18, 2022

Comments

  • Machinerium
    Machinerium over 1 year

    I'm running out of space on the root partition and I want to give it more space but I don't know how. I'm using Ubuntu 16.04, dual boot with Windows. Here is my extended partition on GParted:

    Here is my extended partition on GParted

    As you can see, I don't have much more space on Swap and even if I have it, there is a warning telling me that it's too risky: Moving a partition might cause your operating system to fail to boot

    I have space in sda7 but I don't know how to proceed.

    Any info or approach is welcome :)

  • Machinerium
    Machinerium almost 5 years
    Thanks! I'm not on that scenario and I don't remember how I managed it on that moment but your info is worth to read. Thanks again!