How to Grow a Linux Partition with growpart

Resizing Linux Virtual Machine Disks

This article will show how to grow a partition on your Linux partition to fill the entire disk using growpart. This is useful if you have resized a virtual machine disk, or moved to a larger disk on your desktop or laptop Linux system.

Step 1: Listing and Identifying Storage Devices

To expand the filesystem on your resized disk, you’ll need to first locate the disk using the lsblk command, execute it by running:

lsblk

And you will see output similar to the following listing storage devices and the partitions on them:

Above, you can see that disk sda has a size of 50 gigabytes, but that the volume containing the root partition (sda3) is only 29.5 gigabytes – there is unused space on the storage device.

There may be multiple entries in the output from lsblk – you’ll need to identify the disk you have resized by the size and utilization – it should be apparent which disk has unused space. Usually on single-disk machines, the first and only storage device will be named sda.

You will also need to know the name of the partition your wish to grow – in this case sda3 – usually identified by it having the root mount point of /.

Step 2: Installing growpart

growpart is a utility that makes it super easy to grow a partition. It’s part of the cloud-guest-utils package. Note that while this package is intended to work on cloud-hosted virtual machines, the growpart utility also works just fine on physical machines.

On Debian and Ubuntu, run:

sudo apt install cloud-guest-utils

On Arch, run:

pacman install cloud-guest-utils

On RedHat, run:

yum install cloud-utils-growpart -y

Step 3: Grow your Partition

Once growpart is available, growing a partition to use the entire remaining disk space is as simple as running:

sudo growpart /dev/sda 3

You’ll need to specify the correct partition name above, replaceing sda 3 (note the space! the device and partition number are separated when using growpart) if necessary. growpart is executed with no additional parameters – if the size parameter is not specified, it will default to the available size of the partition.

Now that the partition has been expanded, the file system must be also using resize2fs:

sudo resize2fs /dev/sda3

Note that the space has disappeared in the device path again.

You will see output similar to:

Confirming the change. Once this final step is done, reboot:

sudo reboot