Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Can't resize Ubuntu's main partition with GParted

Writer Andrew Mclaughlin

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 :)

2 Answers

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)

1

The simplest approach to your issue would be to create a new Linux partition using the 7Gb unallocated space, create an ext4 filesystem on the new partition, temporarily mount it on /mnt, move the contents of /var onto the new filesystem in single user mode (make sure you get all the files), delete /var and permanently mount the new filesystem on /var by adding an appropriate entry to /etc/fstab

Effectively what you are doing is freeing up space on the / filesystem by moving the contents of /var to a newly created filesystem whose mount point is /var

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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