๐Ÿ›  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:


๐Ÿงพ Prerequisites


๐Ÿชœ Step-by-Step Instructions

1. Check Current Disk Usage

bash
df -h /

2. List Disks and Partitions

bash
lsblk

Look for:

3. Extend the Logical Volume

bash
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

4. Resize the Filesystem

Assuming you're using ext4:

bash
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

๐Ÿ’ก To confirm the filesystem type:

bash
df -T /

5. Verify Expansion

bash
df -h /

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:

bash
sudo journalctl --vacuum-time=10d sudo apt autoremove sudo apt clean

โœ… Outcome

The root filesystem is now successfully extended. The server will run normally with more disk space, avoiding future outages caused by full disks.


Revision #1
Created 5 April 2025 19:37:27 by joliveira
Updated 5 April 2025 19:38:16 by joliveira