The Short Version
sudo vgs
sudo lvextend -r -L +20G /dev/vg0/data
df -h /data
The first command shows how much space the volume group has left, the second adds 20G to the logical volume data and grows its file system, and the third confirms the new size. Replace vg0, data, and /data with your own names. LVM itself is introduced in LVM basics.
Before You Start
- Take a snapshot or backup: growing a volume is routine, but a typo in a device name is not.
- Check the names:
sudo lvslists logical volumes, andlsblkshows where each one is mounted. - Extend, never reduce by mistake:
lvreduceshrinks a volume and destroys data if the file system is not shrunk first. XFS cannot shrink at all. Never run lvreduce without a backup.
Check the Space in the Volume Group
sudo vgs
sudo lvs
The VFree column of vgs shows the unallocated space in each volume group. If it is zero, add a disk or grow a partition first, as shown below. On Ubuntu Server installed with LVM, the installer may leave part of the volume group unallocated, so vgs often shows space you can add right away.
Choose How Much to Add
| Option | Effect |
|---|---|
-L +20G | Adds 20G |
-L 100G | Sets the total to 100G |
-l +100%FREE | Adds all that is left |
-r | Grows the file system too |
Capital -L takes a size; small -l takes extents or a percentage. To give the root volume of a default Ubuntu install all remaining space:
sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Grow the File System Separately
Without -r, the volume grows but the file system keeps its old size. Grow it afterward while it stays mounted. For ext4, name the device:
sudo resize2fs /dev/vg0/data
For XFS, name the mount point:
sudo xfs_growfs /data
Which file system you have is shown by df -hT; the two are compared in ext4 vs XFS.
Add a New Disk to the Volume Group
Warning: pvcreate writes LVM metadata to the disk and makes anything on it unreachable. Confirm with lsblk that the disk is the new, empty one.
sudo pvcreate /dev/sdc
sudo vgextend vg0 /dev/sdc
sudo lvextend -r -l +100%FREE /dev/vg0/data
After a Disk Upgrade on a Virtual Server
When a plan upgrade makes the virtual disk larger, the extra space sits behind the last partition. Grow the partition, then tell LVM about it:
lsblk
sudo growpart /dev/vda 3
sudo pvresize /dev/vda3
sudo lvextend -r -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
growpart is in the cloud-guest-utils package on Ubuntu and Debian and in cloud-utils-growpart on AlmaLinux and Rocky Linux. Note the space between the disk and the partition number, and use the number of the partition that lsblk shows as the LVM physical volume; 3 is only an example. The full procedure, including partitions without LVM, is in how to grow a partition after a disk upgrade.
Verify the Result
sudo lvs
df -h
lvs shows the new size of the volume and df the new size of the file system. If lvs shows the larger size and df does not, the file system was not grown: run resize2fs or xfs_growfs as shown above.
Common Problems
- Not enough space in the volume group: you asked for more than vgs shows; use a smaller size or a percentage.
- Volume not found: check the path with
sudo lvs;/dev/mapper/vg0-datais the same volume as/dev/vg0/data. - No new space after a disk upgrade: the partition and the physical volume were not grown yet.