LVM (Logical Volume Manager) puts a flexible layer between your disks and your filesystems, so you can grow volumes without repartitioning. AlmaLinux and Rocky Linux use LVM by default, and Ubuntu often does too. This guide explains the pieces and the most common job: using new space after a disk upgrade.
Before you start
- Root or sudo access, and a recent backup (see back up a Linux VPS).
- The extra space already added to the VPS disk, or a new disk attached.
The three LVM layers
- Physical volume (PV): a disk or partition prepared for LVM, e.g.
/dev/vda3. - Volume group (VG): a pool made from one or more PVs.
- Logical volume (LV): a slice of the pool that holds a filesystem, like
/dev/almalinux/root.
sudo pvs
sudo vgs
sudo lvs
lsblkIf lvs shows nothing, your server does not use LVM and you grow the partition and filesystem directly.
Grow the partition after a disk resize
If the disk got bigger but the PV partition did not, grow it. growpart comes from cloud-guest-utils (apt) or cloud-utils-growpart (dnf):
sudo growpart /dev/vda 3
sudo pvresize /dev/vda3Using a new disk instead? Add it to the pool:
sudo pvcreate /dev/vdb
sudo vgextend almalinux /dev/vdbExtend the logical volume and filesystem
Give all free space in the group to the root volume and resize the filesystem in one step:
sudo lvextend -r -l +100%FREE /dev/almalinux/root-r resizes ext4 or XFS automatically, online, without unmounting. To add a fixed amount use -L +20G. Confirm with df -h /.
Note: Volume group names differ: almalinux, rl on Rocky Linux, ubuntu-vg on Ubuntu. Use the names vgs and lvs show.
Warning: XFS can grow but never shrink. Shrinking ext4 requires unmounting and is risky; plan sizes with growth in mind.
Troubleshooting
- Insufficient free space: the VG has no free extents yet; run
pvresizeorvgextendfirst and checkvgs. - NOCHANGE from growpart: the partition already fills the disk, or the VPS has not seen the new size yet; reboot from your control panel.
- Space still missing in
df: the filesystem was not resized; runsudo xfs_growfs /orsudo resize2fs /dev/mapper/....
