A disk-full alert at 03:00 rarely means you need to immediately throw bigger disks at a server. In real infrastructure operations, half of those pages come from runaway container logs, rotated-but-unlinked file descriptors, or exhausted inodes. Expanding an LVM volume before auditing what ate the capacity only buys you another outage a week later.
This workflow covers Ubuntu and Debian (apt) alongside Fedora, RHEL, AlmaLinux, and Rocky Linux (dnf).
Diagram: Original SVG schematic by Ajay Kumar Chaturvedi.
Prerequisites and Safety Checks
Confirm your tools and safety net before inspecting or resizing volumes:
sudoprivileges to inspect root-owned directories,lsof, and LVM metadata.- Install
ncduandlvm2if missing: on Ubuntu/Debian runsudo apt update && sudo apt install -y ncdu lvm2, or on Fedora/RHEL runsudo dnf install -y ncdu lvm2. - Verify whether you actually have unallocated space in an LVM Volume Group (
sudo vgs) or whether you need to attach andpvresizean underlying disk first.
Backup and Destructive Warning: Always create a verified backup or cloud volume snapshot before modifying LVM partitions or resizing filesystems. Extendingext4andXFSonline is well supported, yet power loss or mistyped sizes remain risky. Remember thatXFSfilesystems cannot be shrunk once extended.
Step-by-Step Procedure
Step 1: Check Block Space, Inode Usage, and Filesystem Type
Target OS: Ubuntu, Debian, Fedora, RHEL, Arch.
Start by checking both space and inodes (df -hi) alongside filesystem types (df -hT):
df -hT
df -hiA filesystem showing 40 percent block usage (Use%) and 100 percent inode usage (IUse%) cannot create new files until millions of tiny files (like stale mail queues or session caches) are cleared; adding disk blocks without checking df -hi wastes time. Note the Type column (ext4, xfs, or btrfs) and mount point path before touching anything.
Step 2: Pinpoint Heavy Directories Safely with du and ncdu
Target OS: Ubuntu, Debian, Fedora, RHEL, Arch.
Never scan / without crossing protections, or you will crawl /proc, /sys, and remote NFS shares. Always pass -x (--one-file-system), verified in the `du(1)` manual:
sudo du -xhd 1 /var | sort -hWhen you want interactive drill-down without typing a dozen du commands, launch ncdu in double read-only mode (-rr), which according to the `ncdu(1)` manual disables both interactive file deletion (d) and shell spawning (b):
sudo ncdu -x -rr /varI would skip scanning massive shared file trees directly over slow SSH links with interactive ncdu. Instead, export the scan with -0 or -1 and inspect locally, or stick to targeted du -xhd 1 depth scans.
Step 3: Check for Deleted-But-Open Files When df and du Disagree
Target OS: Ubuntu, Debian, Fedora, RHEL, Arch.
If df -hT insists /var is at 98 percent while ncdu -x only accounts for half the disk, a process is holding an open file descriptor to a deleted file. Deleting a directory entry via rm only drops the link count; the kernel holds the blocks until the process closes that descriptor.
Per the `lsof(8)` manual page, combine +a (logical AND) with +L1 (link count less than 1) and the mount path so lsof does not OR unrelated filesystems together:
sudo lsof -nP +aL1 /varLook at SIZE/OFF and COMMAND (for example a log file rotated improperly without signaling the daemon). Gracefully reload or restart the responsible service via systemctl restart <service> rather than sending kill -9, so the daemon flushes buffers and releases the unlinked inode cleanly.
Step 4: Inspect Physical Volumes, Volume Groups, and Free Extents
Target OS: Ubuntu, Debian, Fedora, RHEL, Arch.
If real data genuinely outgrew the logical volume, inspect the full block stack first (lsblk(8)):
lsblk -f
sudo pvs
sudo vgs
sudo lvs -o +lv_pathLook at VFree in sudo vgs to confirm free space exists in the volume group. If you added capacity to the underlying virtual disk or partition in a cloud console, expand the Physical Volume online first (sudo pvresize /dev/<disk_or_part>).
As the ArchWiki Ext4 guide notes, if your logical volume uses ext4 and relies on e2scrub metadata checks, leave at least 256 MiB unallocated in the volume group instead of consuming 100 percent with -l +100%FREE.
Step 5: Dry-Run and Extend the Logical Volume and Filesystem Online
Target OS: Ubuntu, Debian, Fedora, RHEL, Arch.
Both the `lvresize(8)` manual and ArchWiki's LVM guide document --test (-t) for dry-running metadata changes and -r (--resizefs) to resize supported filesystems (ext4 and XFS) together with the logical volume via fsadm.
First run a dry-run test (-t) adding 10G to your volume:
sudo lvresize -t -L +10G -r /dev/<vg_name>/<lv_name>Once the test output confirms the target LV and size look right, execute the live resize:
sudo lvresize -L +10G --resizefs /dev/<vg_name>/<lv_name>If you prefer explicit control or are on Btrfs (which fsadm does not handle identically across older lvm2 releases), extend the LV first without -r, then grow the filesystem manually using the tool verified for your filesystem:
# 1. Extend LV only
sudo lvextend -L +10G /dev/<vg_name>/<lv_name>
# 2a. For ext4 (works online; takes device path)
sudo resize2fs /dev/<vg_name>/<lv_name>
# 2b. For XFS (must be mounted; dry-run with -n, then grow mountpoint)
sudo xfs_growfs -n /mountpoint
sudo xfs_growfs /mountpointNote that the `resize2fs(8)` manual takes the block device path for ext4, whereas the `xfs_growfs(8)` manual expects the mounted mount point directory (or mounted block device) and cannot operate on an unmounted XFS volume.
Verification and Expected Result
Confirm the logical volume size, remaining VFree capacity, and mounted filesystem total:
sudo vgs
sudo lvs /dev/<vg_name>/<lv_name>
df -hT /mountpointExpected result: lvs shows the expanded LSize, df -hT reports the additional usable space immediately with zero downtime, and vgs still retains a small reserve if using e2scrub.
Troubleshooting
- `Insufficient free space` from `lvresize`: Check
sudo vgs(VFree). Either add a new disk (sudo pvcreate /dev/sdX && sudo vgextend <vg_name> /dev/sdX) or enlarge the partition first (growpart/parted) followed bysudo pvresize. - `fsadm: Filesystem has unsupported type`: Extend the LV without
-r, then runsudo btrfs filesystem resize max /mountpointfor Btrfs, or check ArchWiki XFS / ArchWiki LVM for stackeddm-crypt/ LUKS layers (cryptsetup resizemust run beforeresize2fs). - Disk usage still hits 100 percent minutes after expanding: Re-run
sudo lsof -nP +aL1 /mountpointorsudo journalctl --disk-usageto locate the writer saturating disk blocks before the extra extents fill too.
