๐ Expanding Root Filesystem on Ubuntu with LVM (Virtual Machine)
๐ Use Case
When a virtual machine runs out of space on the root (/) partition, and the underlying disk has already been expanded via the hypervisor or cloud platform.
This guide applies to systems using:
-
Ubuntu Server (e.g., 22.04 LTS)
-
LVM-managed disks
-
A single-root disk layout (e.g.,
/dev/mapper/ubuntu--vg-ubuntu--lv)
๐งพ Prerequisites
-
A snapshot or backup of the VM (highly recommended)
-
Root/sudo access
-
Disk already expanded in the hypervisor (e.g., from 72GB to 250GB)
๐ช Step-by-Step Instructions
1. Check Current Disk Usage
2. List Disks and Partitions
Look for:
-
The disk (e.g.,
xvda) -
The root LVM volume (e.g.,
/dev/mapper/ubuntu--vg-ubuntu--lv) -
Confirm that a partition (e.g.,
xvda3) is larger than the mounted root volume
3. Extend the Logical Volume
4. Resize the Filesystem
Assuming you're using ext4:
๐ก To confirm the filesystem type:
5. Verify Expansion
You should now see the full size available (e.g., ~146GB instead of 72GB).
๐งผ Optional: Clean Up Old Snapshots & Logs
Free up even more space:
โ Outcome
The root filesystem is now successfully extended. The server will run normally with more disk space, avoiding future outages caused by full disks.
No comments to display
No comments to display