Managing Flexible Storage with LVM on Rocky Linux 8 and 9
Learn how to implement and manage Logical Volume Management (LVM) on Rocky Linux 8 and 9 to avoid static partition limits and enable online storage expansion.
11 Dec 2025, 00:27 UTC

The Problem: Static Partitioning Rigidity
Standard disk partitioning fixes a specific amount of space to a directory (like /var or /home) at the time of installation. If a log directory fills up or a database grows beyond its initial allocation, you typically face a choice between risky partition moves or adding new physical disks and migrating data manually. This rigidity often leads to system crashes during critical production spikes.
The Takeaway: Logical Volume Management (LVM) abstracts physical storage into a pool of capacity. This allows you to expand volumes on-the-fly, span a single volume across multiple physical disks, and create snapshots for safe system updates without needing to repartition the drive.
Prerequisites
- A system running Rocky Linux 8 or 9.
- Root or sudo privileges.
- At least one unallocated disk or partition (e.g.,
/dev/sdb).
Implementing the LVM Hierarchy
LVM operates in three layers: Physical Volumes (PV), Volume Groups (VG), and Logical Volumes (LV). You must configure them in this specific order.
Step 1: Initialize Physical Volumes
Prepare the raw disk for LVM use. Run this on the terminal as root:
pvcreate /dev/sdb
Risk: This command initializes the disk; any existing data on /dev/sdb will be inaccessible.
Step 2: Create a Volume Group
A Volume Group acts as a storage pool. You can combine multiple PVs into one VG.
vgcreate vg_data /dev/sdb
Here, vg_data is the name assigned to the pool.
Step 3: Provision Logical Volumes
Carve a usable volume from the pool. For example, to create a 20GB volume for application data:
lvcreate -L 20G -n lv_appdata vg_data
The resulting device will be located at /dev/vg_data/lv_appdata.
Step 4: Format and Mount
LVM creates the virtual disk, but you still need a filesystem. Rocky Linux defaults to XFS.
mkfs.xfs /dev/vg_data/lv_appdata
mkdir /mnt/appdata
mount /dev/vg_data/lv_appdata /mnt/appdata
Expanding Storage Online
The primary advantage of LVM is the ability to grow a volume while the system is running. If lv_appdata reaches capacity, you can extend it provided there is free space in vg_data.
Example: Adding 10GB to a Volume
- Extend the Logical Volume:
lvextend -L +10G /dev/vg_data/lv_appdata - Grow the Filesystem: The OS sees the larger block device, but the filesystem must be told to use it. For XFS (the Rocky Linux default), use
xfs_growfs:xfs_growfs /mnt/appdata
Comparison: XFS vs. EXT4 in LVM
| Feature | XFS (Default) | EXT4 |
|---|---|---|
| Online Expansion | Supported | Supported |
| Online Shrinking | Not Supported | Supported (Offline) |
| Performance | Better for large files/volumes | Better for small files/volumes |
Verification and Diagnostics
To verify the current state of your storage hierarchy, use these three diagnostic commands:
pvs: Checks physical volume health and total size.vgs: Shows how much free space remains in the pool for future expansions.lvs: Lists all logical volumes and their current allocation.
Finally, run df -h /mnt/appdata to confirm the filesystem recognizes the new capacity.
Limitations and Rollback
Limitations: LVM adds a small layer of overhead to I/O. More importantly, XFS filesystems cannot be shrunk. If you allocate 100GB to an XFS volume, you cannot reduce it to 50GB later; you would have to back up the data, delete the LV, recreate it smaller, and restore the data.
Rollback: If a volume creation was a mistake, remove the layers in reverse order:
- Unmount the volume:
umount /mnt/appdata - Remove the LV:
lvremove /dev/vg_data/lv_appdata - Remove the VG:
vgremove vg_data - Remove the PV:
pvremove /dev/sdb
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.