Extending LVM Volumes
One of LVM’s most valuable capabilities is the ability to grow a logical volume and its file system while the system is running, without unmounting or interrupting services. This is the operation you will perform most often in production — a database is growing, /var is getting full, or a log volume needs more space. Knowing this procedure well means you can solve these problems in minutes.
Why extend vs add a new volume
When a logical volume is running out of space, you have two options: extend the existing LV, or create a new LV and move data. Extending is usually faster and requires no data movement. It is the right choice when the VG has free space. Creating a new volume and moving data makes sense when you want to change the file system type or storage location.
Extending a logical volume
# Check current LV size and VG free space
sudo lvs
sudo vgs
# Extend by a specific amount
sudo lvextend -L +50G /dev/vg_data/mysql
# Extend by a percentage of VG free space
sudo lvextend -l +50%FREE /dev/vg_data/logs
# Extend to use ALL remaining free space in VG
sudo lvextend -l +100%FREE /dev/vg_data/backup
# Extend AND resize the file system in one command
sudo lvextend -L +50G --resizefs /dev/vg_data/mysql
lvextend output
Size of logical volume vg_data/mysql changed from 200.00 GiB (51200 extents) to 250.00 GiB (64000 extents).
Logical volume vg_data/mysql successfully resized.
Growing ext4 file systems
# After lvextend, grow the ext4 file system to fill the new LV size
# ext4 can be resized ONLINE (while mounted and in use)
sudo resize2fs /dev/vg_data/data
# Verify
df -h /data # Should show the larger size now
resize2fs output
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/vg_data/data is mounted on /data; on-line resizing required
old_desc_blocks = 25, new_desc_blocks = 32
The filesystem on /dev/vg_data/data is now 65536000 (4k) blocks long.
# One-line: extend LV and resize ext4 file system together
sudo lvextend -L +100G --resizefs /dev/vg_data/data
# --resizefs calls resize2fs automatically after extending the LV
Growing XFS file systems
# XFS uses xfs_growfs, NOT resize2fs
# XFS can also be grown ONLINE (while mounted)
sudo lvextend -L +100G /dev/vg_data/mysql # Extend the LV first
sudo xfs_growfs /var/lib/mysql # Grow XFS to fill it
# NOTE: xfs_growfs takes the MOUNT POINT, not the device
# Or use --resizefs with lvextend (works for both ext4 and XFS)
sudo lvextend -L +100G --resizefs /dev/vg_data/mysql
⚠️ WARNING:
resize2fsis for ext4 only.xfs_growfsis for XFS only. Using the wrong tool will fail safely (it detects the wrong FS type and exits), but--resizefsin lvextend chooses the correct tool automatically, so it is the safest option.
Adding storage to the volume group
# If the VG has no free space, add a new disk first
# Step 1: Initialize the new disk as a PV
sudo pvcreate /dev/sdd
# Step 2: Add it to the volume group
sudo vgextend vg_data /dev/sdd
# Verify free space increased
sudo vgs
vgs output showing new free space after adding a disk
VG #PV #LV #SN Attr VSize VFree
vg_data 3 3 0 wz--n- 1499.99g 500.00g ← 500G free added
# Step 3: Now extend the logical volume (as above)
sudo lvextend -L +100G --resizefs /dev/vg_data/mysql
Conclusion
The standard LVM extension workflow: check free space with vgs, extend the LV with lvextend -L +SizeG --resizefs /dev/VG/LV, verify with df -h /mountpoint. The --resizefs flag handles the file system growth automatically for both ext4 and XFS, so you don’t need to run resize2fs or xfs_growfs separately. If the VG is full, add a new disk with pvcreate + vgextend first, then extend. The entire operation takes less than a minute and requires no downtime.
Need help with Ubuntu administration?
Work directly with Muhammad Irfan Aslam for Ubuntu Server, Linux, cloud, Docker, DevOps, CI/CD, or infrastructure troubleshooting support.
Work with Muhammad Irfan Aslam