📑 Daftar Isi
- Why AlmaLinux LVM Storage Runs Out (and What It Costs)
- Step 0: Audit Before You Touch Anything
- Step 1: Clean Up Before You Extend
- Step 2: Extend the LV Online, Zero Downtime
- Step 3: Volume Group Exhausted? Add a PV
- Step 4: Shrinking LVs – Read This Twice
- Step 5: Snapshots as a Short-Term Safety Net
- Step 6: Verify Before You Close the Ticket
- Quick Troubleshooting Reference
- FAQ: AlmaLinux LVM Storage Optimization
- Q: Can I extend an LV while the server is running?
- Q: Why does df -h show a different size than lvs?
- Q: Can XFS filesystems be shrunk?
- Q: Is an LVM snapshot a safe backup?
- Related Articles
Optimize AlmaLinux LVM Storage: Step-by-Step Guide for Production Servers
Skip the small talk. If you’re here, your AlmaLinux box is out of LVM storage, or it’s slow, or you just want to make sure it never happens. Either way, here’s the exact routine I run on production servers every week. Follow it in order. Don’t skip the audit.
One thing before we start: LVM is logical volume management, and its whole selling point is flexibility. The problem is, most people never use that flexibility. They provision once, forget about it, then panic when df -h hits 100%. I’ve been called at all hours for this exact thing more times than I can count.
Why AlmaLinux LVM Storage Runs Out (and What It Costs)
So what actually goes wrong? Let me break down the real causes I’ve seen in production. First, the filesystem fills up while the volume group still has free space – someone grew the disk in the panel but never extended the LV, or the LV was provisioned too small from day one. Second, the entire volume group is exhausted: zero free physical space, so extending isn’t even an option. Third, the silent killers – snapshots nobody ever removed, journal logs growing forever, and inode exhaustion. From the outside they all look the same: a server that stops writing, services that hang, and a client asking why the site is down.
Impact on production isn’t a maybe. A full filesystem means MySQL or MariaDB can’t flush writes – that’s how you get corrupted databases and an emergency restore at 2 AM. Web servers throw 500s. Logs stop logging. The OOM killer starts picking off processes at random. I’ve seen a small client site go fully dark during peak hours just because /var/log filled up. The fix took five minutes. The panic took an hour.
Here are the causes worth memorizing: (1) no logrotate or badly configured rotation, (2) orphaned LVM snapshots eating space, (3) LVs provisioned tight with zero headroom, (4) usage patterns that changed and nobody caught it, and (5) resizing the disk but forgetting to resize the filesystem. That last one is embarrassingly common. I’ve done it myself. Once. Never again.

Step 0: Audit Before You Touch Anything
Never extend, shrink, or delete on instinct. Audit first. These five commands are my baseline, and I run them every single time:
df -hndf -inlsblknpvsnvgsnlvs
Here’s a real output I hit on a client box (identifiers sanitized):
Filesystem Size Used Avail Use% Mounted onn/dev/mapper/vg01-root 98G 96G 1.4G 99% /n/dev/mapper/vg01-var 20G 19G 900M 96% /varnnVG #PV #LV #SN Attr VSize VFreenvg01 1 2 0 wz--n- 119.24G 0
Read it line by line. Root is at 99%. /var at 96%. And VFree is 0 – the volume group has no free space at all. This is the “volume group exhausted” case. You can’t extend anything here. You need more physical capacity first. Compare that with a different scenario:
VG #PV #LV #SN Attr VSize VFreenvg01 1 2 0 wz--n- 238.47G 137.12G
Different story entirely. 137GB free in the VG, but df still shows a full filesystem. The LV was carved small and nobody ever grew it. In this case you don’t buy anything. You just extend the LV. Knowing which case you’re in decides every step after this, so don’t skip the audit.
Step 1: Clean Up Before You Extend
Clean first. You’d be surprised how often a “shortage” shrinks after a basic cleanup. Start with journald:
journalctl --disk-usagendu -sh /var/log/* | sort -rh | head -20
If journal is hoarding gigabytes, vacuum it:
journalctl --vacuum-size=500M
Safe, non-destructive, keeps recent logs intact. Next, check for orphaned snapshots:
lvs -a -o +lv_attr,lv_size,data_percent
Any snapshot you don’t need? Remove it – the space returns to the VG. Just confirm nothing depends on it first. Snapshot removal is easy; snapshot discipline is the hard part.
Step 2: Extend the LV Online, Zero Downtime
Once you have free space in the VG, extending is straightforward. Check your filesystem type first:
df -Th /
Two cases. XFS:
lvextend -l +100%FREE /dev/vg01/rootnxfs_growfs /
ext4:
lvextend -l +100%FREE /dev/vg01/rootnresize2fs /dev/vg01/root
Both run online. No reboot, no downtime, no maintenance window beyond the seconds these commands take. Then verify:
df -h /

That’s the whole move. Remember: extending the LV without growing the filesystem is the #1 mistake. Always run both commands, in that order. If the output looks healthy, move on.
Step 3: Volume Group Exhausted? Add a PV
If VFree is zero, you can’t extend. Add physical capacity. On a VPS, resize the disk in the provider panel. On dedicated hardware, add a disk or extend the RAID. Then tell LVM about the new device:
lsblk
Say the new disk appears as /dev/vdb. Add it:
pvcreate /dev/vdbnvgextend vg01 /dev/vdb
Confirm:
vgs
VFree went up. Now extend the LV exactly like Step 2:
lvextend -l +100%FREE /dev/vg01/rootnxfs_growfs /
One catch: after resizing in the panel, the kernel may not see the new size yet. If the disk doesn’t show the expected capacity, try:
partprobenecho 1 > /sys/class/block/vdb/device/rescan
That covers most virtio/SCSI cases. If it still doesn’t appear, a reboot is your fallback – schedule it properly.
Step 4: Shrinking LVs – Read This Twice
SAFETY WARNING: Backup Before You Proceed
Shrinking a logical volume is destructive. A wrong order or wrong size permanently corrupts data. Before touching anything:
- Back up your data – database dumps, critical files. See our rsync backup strategy guide.
- Verify the backup actually restores.
- Unmount the filesystem. Never shrink a mounted ext4 volume.
If the backup isn’t confirmed good, stop here. That’s not negotiable.
Shrink is a completely different game from extend. Extend is online and safe. Shrink requires an unmounted filesystem and strict ordering. One hard rule: XFS cannot be shrunk, period. If your filesystem is XFS and you need less space, move the data to a smaller LV or rebuild it. Don’t get clever. For ext4, order is everything:
umount /dev/vg01/data
Check consistency first:
e2fsck -f /dev/vg01/data
Fix any errors before proceeding. Then shrink the filesystem to your target size (20G in this example):
resize2fs /dev/vg01/data 20G
Only after the filesystem is smaller, shrink the LV. Reversing this order corrupts the filesystem. This is the step people get wrong:
lvreduce -L 20G /dev/vg01/data
Verify and mount:
e2fsck -f /dev/vg01/datanmount /dev/vg01/data
Then check the numbers:
df -h /datanvgs
Honest take: I rarely shrink in production. Rebalancing use cases exist, but most of the time extending, cleaning, or rebuilding is safer and faster. When in doubt, take the safe path. That’s the whole job, really.
Step 5: Snapshots as a Short-Term Safety Net
Snapshots are underrated. They give you a point-in-time view of a filesystem without a full copy. Great before a major update or migration. Create one like this:
lvcreate -L 10G -s -n root-snap /dev/vg01/root
Critical detail: an LVM snapshot is not a backup. It shares space with the origin LV. Heavy writes to the origin fill the snapshot; a full snapshot can break the origin LV. So use them, then remove them:
lvremove /dev/vg01/root-snap
If you want to catch storage problems early instead of after they bite, monitor disk usage. We covered the options in Linux disk full monitoring – from cron scripts to full monitoring stacks. Set something up before you need it.
Step 6: Verify Before You Close the Ticket
Final check. Always:
df -hnvgsnlvsnlsblkndmesg | tail -20
That last one gets skipped constantly. Kernel errors – LVM metadata problems, device timeouts – show up there. Five minutes here saves a callback at 3 AM. And if the box still feels heavy, run through high load server troubleshooting next.
Quick Troubleshooting Reference
| Symptom | Likely Cause | Quick Fix |
|---|---|---|
| df -h at 100% but VG has free space | LV never extended | lvextend then resize2fs / xfs_growfs |
| df -h at 100% and VFree is 0 | Physical capacity exhausted | Add a PV, then extend the LV |
| Server slow, I/O climbing | Full filesystem or full snapshot | Check vgs/lvs, purge logs and snapshots |
| “No space left on device” with free space visible | Inode exhaustion | df -i to confirm, then extend the LV |
| Extended the LV but df unchanged | Filesystem never grown | Run resize2fs or xfs_growfs |
FAQ: AlmaLinux LVM Storage Optimization
Q: Can I extend an LV while the server is running?
Yes. Online extension is a core LVM feature. lvextend plus resize2fs (or xfs_growfs for XFS) runs without downtime. It’s non-destructive and designed for live environments. Just don’t forget to grow the filesystem too – that’s the most common mistake.
Q: Why does df -h show a different size than lvs?
df reports the filesystem size; lvs reports the logical volume (block device) size. If you extended the LV but never resized the filesystem, df stays small. That mismatch is almost always the answer. Run resize2fs or xfs_growfs after every lvextend.
Q: Can XFS filesystems be shrunk?
No. XFS only supports growth via xfs_growfs. There’s no supported shrink path. To reduce an XFS volume, move the data to a smaller LV or do a backup and restore. Trying to shrink XFS with workarounds is a fast way to corrupt data.
Q: Is an LVM snapshot a safe backup?
It’s a short-term safety net, not a backup. Snapshots share space with the origin LV, so heavy writes can fill them and break the origin. For real backups, use a separate mechanism like rsync or proper database dumps.
Related Articles
That’s the whole routine. Run the audit, clean up, extend or add a PV, shrink only when you must, keep snapshots short-lived, and verify before you close the ticket. Do that consistently and your AlmaLinux LVM storage stops being a 2 AM problem. Bookmark this guide, and check the related articles if you need the details on monitoring, high load, or backups. Done.