Skip to content

How-to

Extend a filesystem

After you resize a volume, grow its partition and filesystem so the operating system can use the new space. It's done while the filesystem stays mounted.

Before you start

Grow the filesystem

Check that the disk shows its new size, and see how it's laid out:

lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS

Then follow the case that matches what's on the disk.

A filesystem on the whole disk, as Attach a volume sets up, with no partition under vdb. For ext4:

sudo resize2fs /dev/vdb

A partition, such as vdb1, or the boot volume's vda1. Grow the partition first, with its disk and partition number, then the filesystem on it:

sudo growpart /dev/vdb 1
sudo resize2fs /dev/vdb1

XFS, on the whole disk or a partition. xfs_growfs takes the mount point:

sudo xfs_growfs /mnt/data

LVM, where the volume is a physical volume in a volume group, such as data-vg. Grow the physical volume, then the logical volume and its filesystem together:

sudo pvresize /dev/vdb
sudo lvextend -r -l +100%FREE data-vg/data

Breqwatr's Ubuntu, Debian and AlmaLinux images include growpart.

In PowerShell as Administrator, refresh Windows' view of the disks, then grow the partition to the largest size the disk allows. For drive D:

Update-HostStorageCache
$size = (Get-PartitionSupportedSize -DriveLetter D).SizeMax
Resize-Partition -DriveLetter D -Size $size

NTFS grows with the partition, so there's no separate filesystem step.

Add space with a second volume

On Linux with LVM, you can also add space by attaching another volume and adding it to the volume group, instead of growing the first one. Create and attach the new volume, find its device name with lsblk, such as vdc, then:

sudo vgextend data-vg /dev/vdc
sudo lvextend -r -l +100%FREE data-vg/data

The filesystem then spans both volumes, so it needs both attached. Snapshots and backups are of one volume at a time: freeze the filesystem while you take one of each volume in the group.

Check it worked

  • On Linux, df -h /mnt/data shows the filesystem at its new size.
  • On Windows, Get-Volume shows the drive at its new size.