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
Pre-requisites
- Ubuntu with LVM (default for Ubuntu Server installs)
sudoaccess- For Scenario B: new disk attached and visible (
lsblk)
1. Check Current State
lsblk # overview of disks and partitions
sudo pvs # physical volumes and their sizes
sudo vgs # volume groups and free space
sudo lvs # logical volumes
df -h # filesystem usage
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