Ubuntu — Extend an LVM Volume
Two common scenarios:
- Scenario A — the volume group already has unallocated free space (common after Ubuntu's default install, or after extending a VM disk in Proxmox/VMware)
- Scenario B — you are adding a new disk and need to grow the volume group first
How LVM Works
LVM stacks three layers between your disks and your filesystem, and every command in this guide operates on exactly one of them:
Disk/Partition ──► PV (Physical Volume) ──► VG (Volume Group) ──► LV (Logical Volume) ──► Filesystem
- PV — a disk or partition handed over to LVM (
pvcreate,pvresize) - VG — a pool made of one or more PVs; this is where free space lives (
vgextend) - LV — a slice of the VG that behaves like a partition (
lvextend) - Filesystem — ext4/XFS on top of the LV; it does not grow automatically with the LV (
resize2fs/xfs_growfs, orlvextend -rto do both at once)
Growing always means: make sure the layer below has space, then extend upward. Scenario A starts at the LV (the VG already has space); Scenario B starts at the PV (a new disk enters the pool). The most common mistake — extending the LV and wondering why df -h shows nothing — is a forgotten filesystem resize, the top layer.
Pre-requisites
- Ubuntu with LVM (default for Ubuntu Server installs)
sudoaccess- For Scenario B: new disk attached and visible (
lsblk)
1. Check Current State
One command per layer — lsblk for disks, pvs/vgs/lvs for the three LVM layers, df -h for the filesystem:
Key things to look for in vgs output:
VFree shows unallocated space in the VG — if it's non-zero, you are in Scenario A.
Scenario A — Free Space Already in the VG
This is the most common case. Ubuntu's installer often leaves half the VG unallocated.
Extend and resize in one command
The -r flag resizes the filesystem automatically. Done.
Or: two separate steps
ext4:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
XFS (use mountpoint, not device):
Find your LV path
Not sure of the exact path? sudo lvdisplay shows the LV Path for each volume.
Scenario B — Adding a New Disk
Use this when VFree is 0 and you need more underlying storage.
1. Identify the new disk
Look for an unpartitioned disk (e.g. /dev/sdb with no children).
2. Create a partition (optional but recommended)
At the fdisk prompt: n → p → Enter → Enter → Enter → t → 8e → w. The 8e type sets "Linux LVM".
3. Create a Physical Volume
4. Add it to the Volume Group
5. Extend the Logical Volume and resize
ext4 vs XFS
| Filesystem | Check | Resize command |
|---|---|---|
| ext4 | df -T shows ext4 |
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv |
| XFS | df -T shows xfs |
xfs_growfs / (use mountpoint) |
XFS cannot be shrunk — only grown.
Verify
The filesystem size in df -h should now reflect the full allocated space.
Proxmox / VM Workflow
If extending the virtual disk first:
- Resize the disk in the Proxmox GUI (or VMware/vSphere)
- Rescan inside the VM:
echo 1 > /sys/class/block/sda/device/rescan(replacesdawith your disk) - Extend the partition with
growpart:sudo growpart /dev/sda 3(partition number varies — checklsblk) - Run
sudo pvresize /dev/sda3to make LVM aware of the larger PV - Then proceed with Scenario A above
growpart
growpart is part of the cloud-guest-utils package: sudo apt install cloud-guest-utils