Expanding Ubuntu Server Logical Volumes Without Downtime
Ubuntu Server's LVM layout often leaves free space in the Volume Group. Learn to extend a logical volume and grow ext4 or XFS online using lvextend, resize2fs, and xfs_growfs, with snapshot safety and recovery steps.
16 Sept 2025, 22:24 UTC

Ubuntu Server's guided installer commonly uses LVM and leaves unused space inside the Volume Group rather than on a separate partition. When the root filesystem fills up, the instinct is to add a disk or boot from rescue media to repartition. With LVM, you can often extend the logical volume and its filesystem while the system stays online.
The key constraint: growing is safe and usually online; shrinking is high-risk and typically requires unmounting the filesystem or booting into a live environment. Plan expansions, not reductions.
What LVM Actually Abstracts
LVM inserts a management layer between physical disks and filesystems. A Physical Volume (PV) is a disk or partition marked for LVM use. One or more PVs form a Volume Group (VG), a pool of storage. From that pool you carve Logical Volumes (LV), which behave like partitions but can be resized. The filesystem lives on the LV.
Because the filesystem is separated from physical disk boundaries, you can allocate more space from the VG to an LV without moving data to a new disk. The trade-off is boot complexity: if LVM metadata is corrupted, the system may fail to mount root.
Prerequisites
- An Ubuntu Server system installed with LVM (Ubuntu 20.04 LTS, 22.04 LTS, or 24.04 LTS with the
lvm2package). - Free space in the target Volume Group, or a new physical disk to add.
- Root privileges via
sudo. - A current backup or snapshot of the target LV.
- Knowledge of the filesystem type: ext4 or XFS. The growth command differs.
Inspect the Current Stack
Run these commands in a terminal as a user with sudo access. They report the three LVM layers.
sudo pvs
sudo vgs
sudo lvs
sudo df -h /
pvs lists physical volumes and their size. vgs shows the volume group and free space. lvs displays logical volumes. df -h / shows the mounted root filesystem and available space.
Expected check: the VFree column in vgs should show unallocated space. If it shows 0, you must add a PV before extending.
Add a Physical Volume If Needed
If the VG has no free extents, attach a new disk (for example, /dev/sdb) and initialize it as a PV. Replace /dev/sdb with your actual device identifier.
sudo pvcreate /dev/sdb
sudo vgextend ubuntu-vg /dev/sdb
Risk: pvcreate destroys existing partition tables on the target device. Verify the device path with lsblk before running it.
Take a Safety Snapshot
Before modifying a production LV, create a point-in-time snapshot. Snapshots use copy-on-write: the first write to a block preserves the original in the snapshot. They consume space in the same VG.
Example for a root LV named ubuntu-lv in VG ubuntu-vg:
sudo lvcreate --size 10G --snapshot --name root-pre-extend /dev/ubuntu-vg/ubuntu-lv
Limitation: If the VG fills completely, the snapshot may freeze or fail. Size the snapshot to cover expected changes, and remove it after verifying the expansion.
Extend the Logical Volume
Allocate free space from the VG to the LV. To consume all remaining free space:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
To add a specific amount, replace +100%FREE with +50G (or +20480M).
Expected check: lvs should show the new LV size. The filesystem does not automatically use the new space.
Grow the Filesystem
The command depends on the filesystem type.
ext4
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
This runs online on a mounted ext4 filesystem.
XFS
sudo xfs_growfs /
xfs_growfs takes the mount point, not the device path. It also runs online.
Important: XFS filesystems cannot be shrunk. If you might need to reduce the volume later, ext4 is the safer choice.
Expected Checks
Verify the expansion succeeded:
df -h /
sudo lvs
sudo mount | grep " on / "
df -h / should report the larger capacity. lvs confirms the LV size. The mount output confirms the LV is still mounted at /.
Also check /etc/fstab. Ubuntu LVM installations typically reference the LV by UUID or by the /dev/mapper/ path. Confirm the entry still matches the active device.
Recovery Options
If resize2fs or xfs_growfs reports an error, do not reboot immediately. The filesystem may be inconsistent.
- Unmount and check: If the filesystem is not root, unmount it and run
sudo e2fsck -f /dev/ubuntu-vg/ubuntu-lv(ext4 only). - Root filesystem repair: Boot from an Ubuntu live USB, activate the VG with
sudo vgchange -ay ubuntu-vg, then rune2fsck -fon the LV device. - Snapshot data recovery: If data corruption occurs, mount the snapshot read-only and copy critical files back:
sudo mount -o ro /dev/ubuntu-vg/root-pre-extend /mnt. - Remove the snapshot: After a successful expansion and verification, remove the snapshot to reclaim VG space:
sudo lvremove /dev/ubuntu-vg/root-pre-extend.
Rollback note: Removing the snapshot does not undo the LV extension. Reverting an expanded LV requires shrinking the filesystem and LV, which is high-risk and often requires a live environment. Treat the snapshot as a data safety net, not an undo button.
Limitations and Cautions
- Shrinking is dangerous: Reducing an LV requires unmounting the filesystem. XFS does not support shrinking at all. ext4 online shrinking is not supported.
- Boot dependency: LVM metadata corruption can render the system unbootable. Keep
/etc/lvm/backupintact and avoid mixing LVM and non-LVM boot assumptions. - Snapshot overhead: Snapshots consume VG space. A full VG can freeze snapshots and block writes.
- Installer defaults: The Ubuntu Server installer may allocate only a portion of the disk to the root LV, leaving the rest in the VG. Inspect
vgsafter installation to see what is available.
Final Verification
The practical check is df -h / combined with dmesg | tail. If the filesystem size increased and no I/O errors appear, the online expansion succeeded. If the system is under load, monitor sudo lvs -o +segments to confirm the LV uses the new extents.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.