How to resize the root partition size in Ubuntu?

Arunpragash
9 min readJul 9, 2024

--

Hi, I am using the Linux distribution to feel like a techie while executing a simple commands in the terminal, in front of my friends. But it makes me curious to play with commands in terminal instead of GUI when I learned new commands. Unlike windows, I feel linux is my simpler and easier and bit complex when I faced a new issue. Once the problem is solved, then it is okay to face the same issue multiple time.

Today I had faced an issue that the root partition is running out of storage. So I have to decided to re install the OS once again as a fresh one, because I had done this before. But this is not a good idea at all right. So I need a solution for this without losing any data and also I have some other partition with space. So I can extends the root partition size without re installing OS once again. Let’s get into that how we can extend the root partition size.

Before extending the partition make sure backup the important files to avoid data loss. I mean even we do the process correctly unexpectedly any action can lead to data loss.

To make the root partition size increase we need USB flash drive as a bootatble drive. You may arise a question that I said we don’t re install the OS then why we need the bootable drive. In the process of increase the partition size we can’t directly modify the size in the linux distro.

Create a Bootable USB drive

To make a bootable drive we need a USB flash drive with minimum of 8 GB. Make sure that the flash drive don’t contain any data. Because while make a bootable drive it will format the USB drive. And we need an ISO file of an OS. In this blog I am going to use ubuntu. To download the ubuntu ISO file go to official website to download the ISO file.

Ubuntu ISO file downloadBasically I am having memory loss

This is the ubuntu official website. Today Ubuntu has a version of 24.04 LTS. Click the download button it will redirect to another page and automatically prompt for downloading the iso file.

Download ISO file

You can choose the path where to store the ISO image. It is almost 6 GB file. Don’t ask me that “I am already running out of the storage where to store the file”. I am telling you that how could we increase the root partition size so that mean I have a space in another partition.

It takes a long to download the file. So I am using my old ISO file which is 20.04 version ISO file for this process. The version doesn’t make any changes here to increase the partition size.

Now I am going to make my USB drive as bootable drive. I am using disks application which is pre installed in the ubuntu device.

Click windows button in the keyboard or in the show applications search for disks.

Disks application in ubuntu

When you select the disks it will open the disk manager applciation.

Here you can see two disks. First one is my storage SSD in my laptop and the second one, which is select right now is a flash drive.

Now click the settings button ⚙️ in the flash drive. It will show you some options. In that options click the format partition. It will format the data, which is in the USB drive.

It will asks you Name for the drive and it is optional. Enable the Erase toggle to erase all the data. And the type should be choosen as FAT.

It will ask confirmation for erasing all the data from the USB Drive. Proceed with format option, once you don’t have important files in the USB drive.

This will take some time. Wait for completing.

Now click the settings button ⚙️ in the flash drive. It will show you some options. In that options click the restore partition image.

The option is in the second option from the bottom. It will ask you to select the ISO image from the storage.

Click the None option it will open files, then you can navigate to the place where you have an ISO file.

Once you selected the ISO file then open it.

Once the image is opened then click the start restoring button.

It will prompt you for confirmation to restore the image and all data will be lost from the USB drive. Once you click restore it will prompt you password for proceed.

Wait for the process to complete. Waiting patiently is most crucial in the current situation in the word.

Once the image is restored we are ready to go. Restart the system and enter into the boot menu of system. Most of the system is entered into boot menu by continuous click of Esc or F2 or F8 or F11 or F12 or Enter. Acer, Dell, Gigabyte—F12, Asus — Esc, F8, or F12 Hp — Esc or F9, Lenovo — Enter Esc or F2 or F12.

Make sure to connect to your laptop to power source while doing this process.

Before extending the root partition, I am having 126GB, and I need empty space. Once we get an empty then we can go with restart.

Make a free space

To extend the root partition I need a space which is un-allocated, but in my case, there is no free space is available. So I am going to format a partition or we can resize the partition which has more space. For do this process, I am using the gparted. Which is in the ubuntu by default. Suppose you don’t have it install it by

sudo apt install gparted

I just opened my gparted

Here you can see that there are four partition, In my root partition I have 19.25 GiB which is free space and Adjacent partition has 100.GiB which has some data. So I have to resize the third partition /dev/nvme0n1p5 by right click on the partition will show some options.

In that option I am going to click the resize or move option to resize the partition.

In this just drag the left side cursor to right to resize the partition.

I tried to create half of the drive should be un allocated.

It will promt you some warning that OS failed to boot. But that’s not an issue here, we don’t resize the root partition. So I clicked ok.

Here you can see that 65.26 GiB is un allocated. But it doesn’t any effect untill it is apply. Click the green tick button to apply it.

It will copy the data which are in the unallocated space to allocated space. Make a free space.

Now We need to make the unallocated space to adjacent of the root partition. So that only we can re size the partition.

For that I am going to move the /dev/nvme0n1p4 to right side and make the unallocated space to left.

here you can drag the partition to right without resizing it. Just make the cursor at center of the partition and move it to right. Do apply it again.

Once you moved and applied it will move partition to right. It will copy all the files and directories to moved space.

Now we are ready to go with the USB flash drive.

Use Bootable drive to boot an OS from Pendrive

Now plug the USB flash drive and reboot the system by GUI mode or open terminal and type reboot press enter. Find the keys to make you system to get into boot menu.

Once you entered into the boot menu, it will show you different options. Choose you flash drive from that option.

select the USB drive.

Select Try Ubuntu

Select Try Ubuntu. I just take the image in my mobile so it like shake. But no worries just select the try ubuntu option

It will show you ubuntu interface it is booted from your pen drive.

Open Gparted.

Here you can see the space and unallocated space. Now select the root partition and click resize option and resize the un allocated space.

Apply by clicking the gren tick button in the option

Once the process is finished. Then reboot the device.

While rebooting you will see

During this time remove the USB flash drive and press enter. It will restart your system. Once the system is restarted open disks

Now you can see that the root partition is right now as 198 GB. Before the partition it is 126 GB. Finally I solved my problem. You may ask that I have 20 GB free space before extending the root partition then why I tried to expand this. Actually I am lazy person I don’t manage the storage. There are many junk files are there in my System. Which mostly not used one. When ever the issue may arise that I am running out of storage.

The best part is that I am working seriously for the output, but I will get the storage is running out of space. Preventing that error before it occurs.

Let’s create an blog while I am facing an another issue.

← — — — — — -Why this blog — — — — →

I would like to document the process of my problem solution so that I can revisit to this for reference. If you are also facing an issue document your problem so that you can understand better than my blog.

--

--