Logical Volume Manager (LVM) is a flexible disk management system that allows you to create, resize, and manage storage volumes on RHEL 8 without the limitations of traditional partitioning. By abstracting physical disks into logical volumes, LVM lets you grow or shrink filesystems on the fly, take point-in-time snapshots, and pool multiple disks into a single large volume group. This tutorial walks you through creating an LVM setup from scratch on a fresh disk, extending volumes, snapshotting data, and safely removing LVM resources. All commands are run as root or with sudo on a RHEL 8 system.
Prerequisites
- RHEL 8 system with at least one unpartitioned disk (e.g.,
/dev/sdb) - Root or sudo access
lvm2package installed (dnf install -y lvm2)- Basic familiarity with the Linux command line
Step 1 — Initialize the Physical Volume
Before LVM can use a disk, you must mark it as a physical volume (PV). The pvcreate command writes LVM metadata to the beginning of the disk, making it available to a volume group. Verify the disk is visible with lsblk before proceeding.
lsblk
pvcreate /dev/sdb
pvdisplay /dev/sdb
The pvdisplay output confirms the PV size, the associated VG (empty for now), and the number of free physical extents. Each extent is typically 4 MiB and is the unit LVM allocates when creating logical volumes.
Step 2 — Create a Volume Group
A volume group (VG) pools one or more physical volumes into a single storage pool. The vgcreate command names the VG and associates the PV with it. You can add multiple disks at once by listing them after the VG name.
vgcreate myvg /dev/sdb
vgdisplay myvg
The vgdisplay output shows total, allocated, and free PE count. Note the VG Size and Free PE fields — you will draw from the free space when creating logical volumes.
Step 3 — Create a Logical Volume and Format It
A logical volume (LV) is the functional equivalent of a disk partition. Use lvcreate to carve out a named slice of the VG, then format it with XFS — the default filesystem for RHEL 8.
lvcreate -L 10G -n mylv myvg
lvdisplay /dev/myvg/mylv
mkfs.xfs /dev/myvg/mylv
The device path /dev/myvg/mylv is a symlink that LVM creates automatically. You can also reference it as /dev/mapper/myvg-mylv. Either path works for mounting and formatting.
Step 4 — Mount the Logical Volume Persistently
Create a mount point, mount the LV immediately, and add an entry to /etc/fstab so it mounts automatically at boot. Using the device mapper path in /etc/fstab is reliable across renames.
mkdir -p /data/mylv
mount /dev/myvg/mylv /data/mylv
df -h /data/mylv
# Add to /etc/fstab for persistent mounting
echo '/dev/myvg/mylv /data/mylv xfs defaults 0 0' >> /etc/fstab
mount -a
systemctl daemon-reload
Step 5 — Extend the Logical Volume Online
One of LVM’s greatest strengths is live resizing. Use lvextend to add space to the LV, then xfs_growfs to expand the XFS filesystem to fill the new space. Unmounting is not required for XFS online growth.
# Extend the LV by 5 GiB
lvextend -L +5G /dev/myvg/mylv
# Grow the XFS filesystem to fill the new LV size
xfs_growfs /data/mylv
# Confirm the new size
df -h /data/mylv
lvdisplay /dev/myvg/mylv
Step 6 — Create and Use an LVM Snapshot
Snapshots capture the state of an LV at a point in time using copy-on-write. They are useful for backups and safe testing of configuration changes. The snapshot LV lives in the same VG and needs only enough space to hold changed blocks.
# Create a 1 GiB snapshot of mylv
lvcreate -L 1G -s -n mylv_snap /dev/myvg/mylv
# Mount the snapshot read-only to inspect or back up data
mkdir -p /mnt/snap
mount -o ro /dev/myvg/mylv_snap /mnt/snap
ls /mnt/snap
# Remove the snapshot when done
umount /mnt/snap
lvremove /dev/myvg/mylv_snap
Step 7 — Remove LVM Resources Safely
When decommissioning an LV or the entire LVM stack, always unmount first, then remove in reverse order: LV → VG → PV. Skipping steps or removing in the wrong order will result in errors or data loss.
# Unmount and remove the LV
umount /data/mylv
lvremove /dev/myvg/mylv
# Remove the volume group
vgremove myvg
# Remove the physical volume label
pvremove /dev/sdb
# Remove the fstab entry manually or with sed
sed -i '//dev/myvg/mylv/d' /etc/fstab
Conclusion
You now have a complete understanding of LVM on RHEL 8: from initializing physical volumes and building volume groups, to formatting, mounting, and persistently managing logical volumes. You also learned how to extend volumes online without downtime, create point-in-time snapshots for backups and rollback, and safely tear down the entire LVM stack. LVM is a foundational storage skill for any RHEL administrator, enabling flexible, non-destructive disk management at scale.
Next steps: How to Set Up NFS File Sharing on RHEL 8, How to Set Up Software RAID with mdadm on RHEL 8, and How to Automate Backups with rsync and cron on RHEL 8.