All your drives on Ubuntu are divided into multiple partitions. Multiple partitions let you store data separately on the same drive. In general, keeping your OS on one partition and your personal files on the other is a good idea.

Once a partition is created, it has a specific size, and you're limited to it. Many users realize later that they need more size or their needs simply change and have to shrink specific partitions. Luckily, there are ways you can resize an Ubuntu partition to expand or shrink its size.

In this post, we'll tell you everything you need to know about changing the Ubuntu partition size and give you the exact steps you must follow during the process. So, let's start.

In this article
    1. Installing GParted on Ubuntu
    2. Resizing Ubuntu Partitions in GParted

Preparations for Resizing Ubuntu Partitions

Before you resize a disk partition on Ubuntu, you need to know some important things. You should know some factors when resizing an Ubuntu partition to ensure the process goes smoothly. Here's what you need to know:

  • Avoid resizing an Ubuntu partition while it's mounted. That includes all partitions on your Ubuntu, both the ones with system files and the ones with personal files. In other words, to resize a partition on Ubuntu, you must run your system via USB.
    Ubuntu Live can boot your system from a DVD or USB. When you get to the part, select "Try Ubuntu without installing" to quickly resize partitions without installing a new OS.
  • Resizing a partition can result in various issues. Even if you do everything correctly and your system is in great shape, you never know when something might happen. That's why you should back up your data on your resizing drive. Additionally, consider getting data recovery software to recover lost files from the resized partition.
  • It's also important to know that you can't expand an Ubuntu partition without enough space on the drive. You can check this by looking at the graphic interface in GParted.

Boot From USB or Disk to Resize Your Ubuntu Partition

You will need a bootable USB drive with a Ubuntu or CD installation to resize your partition. Insert the CD or the USB flash into your computer and restart it. If you don't have one, you can download the Ubuntu ISO from the official Ubuntu website and burn it to a disk.

Alternatively, after downloading the ISO file, you can use a Startup Disk Creator app in Ubuntu to create a bootable USB. Once you've inserted your bootable USB media, restart your computer and press F1, F2, or Delete during the load screen to enter BIOS.

Change the boot order to a USB drive and restart. You will get to the installation window below:

running ubuntu from an usb

Select your language and click Try Ubuntu to boot your system from the drive.

Once you've done that, you can resize your Ubuntu partition.

How to Resize Ubuntu Partitions Using GParted

One of the best ways to resize your partition is to use the GParted tool. This tool can't resize partitions using a simple graphical interface. But before you can use it, you will have to install it. Luckily, GParted comes with the default package repository.

Installing GParted on Ubuntu

  1. Open the terminal by pressing CTRL + ALT + T.
    accessing the terminal in ubuntu
  2. Start updating your package list by typing the command "sudo apt update."
    sudo apt update command
  3. Wait until the update is complete and run "sudo apt install gparted" to install GParted on Ubuntu.
    sudo apt install gparted command
  4. Once GParted has been installed, type "gparted" to access the tool.
    accessing gparted command

Before we get to the steps for resizing Ubuntu partitions using GParted, let's talk about the tool itself and what you'll see:

gparted user interface
  • The area marked with the number 1 is the graphical representation of the drive. Here, you can see your partitions, their location on the drive, and the space they take.
  • The area marked with the number 2 includes the details of all partitions on the drive, including unused space, used space, size, formatting, and names. A partition can't be modified if it has a key icon next to it. You can also see how much unallocated space you have on the drive.
  • The area marked with the number 3 lets you change between the drives on your computer.

Resizing Ubuntu Partitions in GParted

  1. Locate the partition you want to resize on Ubuntu. In our example, there's only a single partition, which takes about half the drive space.
    gparted partition information
  2. Right-click the partition and select Resize/Move.
    resize option in gparted
  3. The first option to resize the partition is to click on the arrow and slide it left or right to configure it to the correct size (figure 1).
  4. The second option is to input the exact size of the partition in MiB or allocate the amount of free space this partition should have. (figure 2)
  5. Regardless of your method, the next step is to click Resize/Move at the bottom right corner. (figure 3)
    resizing ubuntu partition in gparted
  6. You can now see pending changes at the bottom of the tool that need to be confirmed. (figure 1) If you're happy with the changes you want to make, click on the green tick icon. (figure 2)
    confirming partition resize in gparted
  7. Click Apply to go through with the changes.
    applying partition resize in gparted
  8. Wait until the process is complete. When you see the "All operations successfully completed" message, click Close.
    finishing partition resize in gparted
  9. Check if the partition has been successfully resized and turn off GParted.
    gparted partition details

How to Change Ubuntu Partitions Using the Terminal

Another option to resize an Ubuntu partition is to use the terminal. It's the preferred method if you're using a Ubuntu server or some other terminal-based operating system. Alternatively, this is an excellent method to change the partition remotely.

Similarly to the GParted method, the Ubuntu partition you want to shrink or extend can't be mounted. You should also use Ubuntu Live instead of running the commands through the installed OS when resizing partitions with this method.

  1. Access the terminal by pressing CTRL + ALT + T.
  2. Type "sudo lsblk -d | grep disk"
    sudo lsblk -d grep disk command
  3. Check the drive names and memorize the one on which you want to change partitions.
    partition information in terminal
  4. Type "sudo parted" to enter the tool for resizing partitions.
    sudo parted command in terminal
  5. Type "select /dev/DEVICE " and replace DEVICE with your drive name.
    select dev device command
  6. If the drive is successfully selected, you will see this message.
    selected drive in terminal
  7. Use the "print" command to print out the information about the drive, including its partitions.
    print command in terminal
  8. You will get something like this.
    partition information in terminal
  9. Type "resizepart" to resize the partition.
    resizepart command in terminal
  10. Type the partition number and press Enter.
    partition number message in terminal
  11. The next step is to type where the drive will end. Remember that two partitions can't intersect, and you must leave a bit of space between them.
    partition drive end in terminal
  12. Type "print" to verify the changes you've made. In our case, we've increased the partition size to 30GB.
    partition size changed in terminal

Bonus Tip: How to Recover Lost Partition Data After Resizing

If you've forgotten to back up your files or couldn't do it for some reason, you might lose files on your resized partition. Even if you follow all the steps correctly, it's possible to lose data. For example, if you change the file system or the partition type during the process or change from a primary to a logical partition, there's a high chance you'll lose data.

That's why you should use a capable data recovery tool like Wondershare Recoverit to recover deleted files or partitions successfully. For this method, you will need another computer with Windows or Linux.

Free Download
Free Download

Download and install the app on your working computer and follow these steps:

  1. Launch the app, select the NAS and Linux option and the left menu panel and click Linux Recovery.
    linux recovery in recoverit
  2. You will see this screen. Add all the required information and click Connect.
    connecting linux with windows in recoverit
  3. The app will automatically start scanning your device. You can see progress in real-time and stop scanning if you've found the missing files.
    recoverit scanning process
  4. Once the scan is complete, select the files to preview them. If these are the files you want to recover, click Recover.
    previewing files in recoverit
  5. Select the save destination on your working computer and click Recover.
    saving recovered files using recoverit

Conclusion

We hope this guide helps you use the Ubuntu command line successfully to resize partitions. Whether you want to shrink or extend your partition, the steps remain the same – the only difference is the size changes you make.

Follow the steps carefully; we guarantee you can successfully change your Ubuntu partition size. Remember to back up your files and keep a recovery tool like Recoverit close by in case something goes wrong to ensure none of your files get lost.

Free Download
Free Download

FAQ

  • Can I shrink an Ubuntu partition?
    Yes, it's possible to shrink and extend an Ubuntu partition using GParted and the terminal. The steps are the same. You only have to lower the size when allocating space.
  • Why change an Ubuntu partition size?
    You can change an Ubuntu partition size to reclaim unused space, improve performance, create new partitions, reallocate disk space, free up space on other partitions, or adjust the size of virtual disks.
  • How do I change the size of my home partition in Ubuntu?
    To change the size of your Ubuntu partition, you can use two fundamental methods: the Ubuntu Terminal or Gparted.
  • How do I resize Ubuntu 20.04 in GParted?
    To resize Ubuntu 20.04 in GParted, follow these steps:
    1. Install and launch GParted.
    2. Select the drive you want to resize.
    3. Unmount the desired partition.
    4. Resize the partition.
    5. Apply changes and wait for the process to complete.
    6. Reboot your system.
David Darlington
David Darlington Nov 16, 24
Share article: