How To Safely Extend a Partition on Ubuntu (GUI & Commands)

Resizing partitions is not something to be taken lightly, you can screw up your data with one wrong step or command parameter. When I was a Linux system administrator, I often had to do this on critical servers, and I’ll share all of my tips with you in this tutorial.

The easiest and safest way to extend a Linux partition is to boot on a Live-USB Ubuntu and to use the tool named Gparted. When there is no GUI available, the commands fdisk and resize2fs can do the same thing.

Don’t worry, I’ll explain all of the steps in detail in this article, starting with the graphical method that seems easier and safer for most systems.

I answer your questions - Raspberry...
I answer your questions - Raspberry Pi FAQ

How To Extend a Partition with Gparted (GUI)

Get My Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

Here are the main steps to extend a partition on Ubuntu:

  • Identify the partition name (ex: /dev/sda3).
  • Create and boot on a Live-USB key if you want to extend the system partition.
  • Use Gparted to resize the partition.

I will now give you all of the steps in detail.

Identify the partition

The first step is to identify the partition you want to expand. In most case, this shouldn’t be complicated.

On a desktop computer, you probably have one big partition with your system and all of your files in it. You will need to be careful with more complicated installations, like if you have several hard drives, or if you divided your disk in several partitions (system, data, etc.).

On your system, you can open the “Disk” tool to quickly see how your system is installed, and find the device name for your partition:

Raspberry Pi Bootcamp
Sale: 10% off today.
Take it to the next level.
I'm here to help you get started on Raspberry Pi.
Learn all the skills you need in the correct order.

In this typical case, there are three partitions on the disk, and almost everything is in the third one. The device name is /dev/sda3. Try the same steps on your system, and find the name for the partition you want to extend.

In general, the system disk will be named /dev/sda, and the number after that correspond to the partition identifier. If you have a second disk for your data, that might be /dev/sdb1 for example.

Optional: Boot on a Live-USB key

It’s not possible to resize a partition that is currently mounted, so you need to unmount it first. But a system partition can’t be unmounted, that’s why a Live-USB key is often required.

When you boot on a Live-USB key, the system is no longer loaded from the hard drive, and we can unmount the partition safely.

This process is only required if you want to extend the system partition, in other cases you can do it directly from your Ubuntu session:

  • Download Ubuntu from the official website.
  • Flash it on a USB key.
    You can use a tool like Etcher, Rufus or the one you prefer and the system you use.
    etcher menu
  • Insert the USB key on your computer, and boot on it.
    On most computers, you’ll need to press F12 or DEL to get the boot menu, and boot on it instead of the system on your hard drive.
  • Choose the live boot (we don’t want to reinstall Ubuntu).

From there, you can follow the same steps, as if your partition is no longer hosting your system.

When editing a partition table, you can easily break something which can result in your computer being unable to reboot properly. It’s highly recommended to create a backup of your data, especially for critical servers or files you don’t have anywhere else (don’t forget the configuration files).

If you don’t know how to do this, you can follow this tutorial. It’s for Raspberry Pi, but you can use the same steps and tips.

Install Gparted

Gparted is a tool I love to manage any partition task. In an intuitive interface, you can resize, create or delete partitions in a few clicks.

You can find it in the Ubuntu Software catalog:

Or you can install it with apt:
sudo apt install gparted

Master your Raspberry Pi in 30 days
Sale: 10% off today.
Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.
Learn useful Linux skills and practice multiples projects.

Install it and start it to see your disk’s partitions (it should look like the Disk tool you used in a previous step). You’ll need to type your password to unlock the administrator mode.

It’s a bit more detailed, as you can see all the partitions at a glance, the file system, mount point and different sizes (total, used, unused). The yellow on the graphical visualization shows the used space.

If the partition you want to resize is NOT the system partition, you need to unmount it first. Do a right-click on it and choose “Unmount”. Then you can follow the next steps.

Extend the partition

Once on Gparted, you can quickly resize any partition by following these steps:

  • Make sure to select the correct drive in the top-right corner.
    If you rebooted on a Live-USB key, the key is now probably /dev/sda and your system is on /dev/sdb. The partition number doesn’t change, just the drive name.
  • For the example, let’s say you have something like that:

    On /dev/sdb, I have one partition that is about 8GB, but my disk is 16GB total. I want to extend /dev/sdb1 to use the full size.
  • Right-click on the partition you want to extend, and choose “Resize/Move”.
    This window shows up:
  • From there, the easiest way would be to grab the right arrow on the graphical visualization and move it to the right. But you can also use the form below and update the new size field to the maximum value.
  • Once done, click on “Resize/Move”. Gparted will show you the result directly.
  • If it’s fine for you, click on the green tick to apply the changes

That’s it! After a few seconds (or minutes, depending on the size of your disk), your partition table has been updated, and you can now use your whole disk. If you are on a Live-USB system, you can now reboot on your normal session and enjoy your new disk space.

If the resized partition wasn’t your system partition, don’t forget to mount it back (or to restart your system).

Reminder: Remember that all my Patreon supporters get access to this website without ads, early access to my videos and much more. You can become part of this community for as little as $3 per month & get all the benefits immediately.

How to Extend a Partition from the Command Line

Get My Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

Overall, the steps to extend a partition from a command line are the same as with a GUI:

  • Identify the partition name and the disk space available with fdisk.
  • Unmount the partition with umount.
  • Use resize2fs to extend the partition size.

When possible, I highly recommend using a Live-USB key with a GUI to do these steps. A mistake can easily happen, especially when you use the command line. Using the previous method will be easier and less risky.

Only follow these steps when you can’t reboot the computer (so when you are not resizing the system partition).

Identify the partition to resize

On a server without GUI, we can’t use Gparted or the disk tool to find the partition name. In this case, the “fdisk” command will do the same thing for you:
sudo fdisk -l

The output will include several paragraphs like the one on the pictures, each one corresponds to a physical disk. For example, on this screenshot, you can see the /dev/sda drive, which is 16 GiB and contains a partition that takes only 2 Gib.

Master Python on Raspberry Pi
Sale: 10% off today.
Get the eBook.
Do more with your Raspberry Pi, learn the useful concepts and take the shortcuts.
You miss half of the fun of using a Raspberry Pi if you don’t know anything about Python.

I will show you how to extend this partition.

When editing a partition table, you can easily break something and have your computer unable to reboot properly. It’s highly recommended to create a backup of your data, especially for critical servers or files you don’t have anywhere else (don’t forget the configuration files).

If you don’t know how to do this, you can follow this tutorial. It’s for Raspberry Pi, but you can use the same steps and tips.

Extend a partition from the command line

Here are the steps to follow to resize a partition from the command line:

  • Make sure the partition is not mounted, use:
    sudo umount /dev/sda1
    Adjust the parameter to fit your partition name (/dev/sdb3 for example).
  • Open fdisk to edit the partition table:
    sudo fdisk /dev/sda
  • Delete the existing partition:
    Type the corresponding number (in my case I have only on partition, but if it’s /dev/sdb3 for example, you need to type “3”).
    This step can be scary, but don’t worry, you shouldn’t lose your data as we don’t format the disk content (make sure to have a backup anyway!).
  • Create the new partition:
    Answer the questions to create a new partition, you should probably keep the default values. Just set the new partition size by using something like “+8GB” for the last sector.
  • Check that the new partition table is what you wanted:
  • And if so, write the change to your disk:

Here is my full log if you are unsure at some point:

The last step is to actually resize the file system to fit the new partition size, you can do this easily with:
sudo resize2fs /dev/sda1

You can now mount your partition and enjoy more free space!
sudo mount /dev/sda1
Or something like:
sudo mount /dev/sda1 /mnt/data

What if there is another partition at the end of the one I want to extend? In some cases, you have the main partition (let’s say /dev/sda1) and then your data partition (/dev/sda2) and finally some unallocated disk space at the end. To extend /dev/sd1, you’ll need to first move /dev/sda2 to the end of the disk. You can do this with Gparted and then follow the same steps to resize /dev/sda1.

This tutorial doesn't work anymore? Report the issue here, so that I can update it!

0 0 votes
Article Rating

Patrick Fromaget

I'm the lead author and owner of My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Notify of
Inline Feedbacks
View all comments

Recent Posts

Master your Raspberry Pi - 10% off