How to resize Linux partition with Gparted?

Today, I just messed up with my system (Ubuntu 16.04 LTS), but now everything is fine! Actually, I was going to resize my Linux partition with Gparted, but I didn’t know that a freaking experience was waiting for me. To explore the same, you may visit my previous post on Grub Rescue. In this post, find out how to use Gparted for resizing Linux partition.

Step 1: Open Gparted

 

resize_linux1

For resizing a Linux Partition you should have unallocated space around it. But, as you may see I have “linux-swap” partition between “ntfs” (that I am going to unallocate soon) and “ext4” (that I wanted to extend by merging it with unallocated partitions).

What is Linux-swap partition?

This partition acts to handle the overflow of your RAM. If your memory is filled up completely, any additional applications will be run off of the SWAP partition rather than memory.

Possible solutions to remove linux-swap.

  • Shift swap partition such that, unallocated space preceeds it. For this, you may refer this link.
  • Or simply, delete it.

Note: I am going for the second one. But you are recommended to explore the web to find out if you really need “linux-swap” partition or not before proceeding ahead. Refer this link. Also, in my case, all my Linux-partition, unallocated partition, and ntfs partition are available in a single Extended-partition. If this is not the case with you, I recommend you to explore the web.

Step 2: Delete linux-swap

On linux-swap:

  • right-click -> swapoff
  • right-click -> delete

This will unallocate the linux-swap partition. See the image below.

resize_linux2

Step 3: Unallocate ntfs

Note: my /dev/sda6 (ntfs) is my Local-Disk: D (in Windows). I have already formated that partition from Windows, you are also recommended to either shift or remove data from the partitions you are going to unallocate.

To unallocate the partition.

  • right-click -> delete

This will merge partitions.

  1. Unallocated partition: from step 2.
  2. /dev/sda6: from step 3.
  3. Unallocated partition: that is followed by /dev/sda6.

See the image below (after merging all unallocated partitions).

resize_linux5

Step 4: Merge ext4 with unallocated partition

Now, you have to resize your ext4 to merge with unallocated partition. For this go to ext4.

  • right-click -> resize
  • shift the slider to the right-most
  • click “resize”

After you are done with resizing the output would be like.

resize_linux6

Here you may see, that linux partition is successfully merged with unallocated partitions. But still, the changes are not applied.

Step 5: Apply the changes

To apply the changes, just click on the “tick” symbol in green color at tool-bar of Gparted. And confirm, if prompted for a confirmation.

It would take few minutes to complete the process.

And soon! You are good to go. You have successfully resized your linux partition with Gparted.

Step 6: Removing the linux-swap traces

This step is only applicable if you deleted “linux-swap”.

  • Comment out the swap UID line from the file: /etc/fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    # / was on /dev/sda6 during installation
    UUID=ff0568ec-114e-493b-985d-39ba043467d0 / ext4 errors=remount-ro 0 1
    # swap was on /dev/sda7 during installation
    #UUID=670bf5a5-5131-4751-90ea-88d6211761b8 none swap sw 0 0
  • Comment out the swap UID line from the file: /etc/initramfs-tools/conf.d/resume

    #RESUME=UUID=670bf5a5-5131-4751-90ea-88d6211761b8
  • run these commands
    $ sudo update-initramfs -u
    $ sudo grub-update

Step 7: Confirming resizing

Just run this command and you’ll see something like.

$ df -h | grep '^/'
/dev/sda5 170G 40G 123G 25% /

Here /dev/sda5 is Linux partition. Totol memory: 170GB. Used: 40GB. Free: 123GB.

This complete procedure worked fine for me, but I know there must be many more cases of resizing that I haven’t discussed like.

  • The Extended partition is out of Linux or unallocated partition.
  • Linux-swap is not deleted, etc.

See you in the next post! Hope this one helped you out. And for queries and suggestions to improve this post, please feel to write in the comments section below.

Thanks for reading!

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s