How to Configure LVM on RHEL 7

Logical Volume Manager (LVM) is one of the most powerful storage management tools available on Linux. Unlike traditional partitioning, LVM introduces an abstraction layer between physical storage devices and the file systems that use them, enabling administrators to resize volumes online, create snapshots for consistent backups, and pool multiple physical disks into a single flexible storage group. On RHEL 7, LVM is the default storage configuration for most installations, making it essential knowledge for any system administrator. This tutorial walks through the complete LVM workflow — from initializing physical volumes to extending live file systems and creating snapshots — all on RHEL 7 using yum and systemctl.

Prerequisites

  • A RHEL 7 system with root or sudo access
  • One or more additional block devices (e.g., /dev/sdb, /dev/sdc) — these can be physical disks, partitions, or virtual disks
  • The lvm2 package installed (it is installed by default on most RHEL 7 systems)
  • Basic familiarity with Linux disk concepts (partitions, file systems, mount points)

Verify that lvm2 is installed:

rpm -q lvm2

If it is not present, install it:

yum install -y lvm2

Step 1: Identify Available Block Devices

Before creating any LVM structures, identify which block devices are available and unused. The lsblk command gives a clear tree view of all block devices and their current mount points.

lsblk

Sample output:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk
├─sda1   8:1    0    1G  0 part /boot
└─sda2   8:2    0   19G  0 part
  ├─rhel-root 253:0  0   17G  0 lvm  /
  └─rhel-swap 253:1  0    2G  0 lvm  [SWAP]
sdb      8:16   0   10G  0 disk
sdc      8:32   0   10G  0 disk

In this example, /dev/sdb and /dev/sdc are unpartitioned and available for LVM use. You can also use fdisk -l or pvs to cross-reference existing LVM structures.

Step 2: Create Physical Volumes with pvcreate

The first step in setting up LVM is to initialize block devices as Physical Volumes (PVs). This writes LVM metadata to the device, marking it as usable by the LVM subsystem.

pvcreate /dev/sdb /dev/sdc

Expected output:

  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.

Verify the PVs were created:

pvdisplay

Or use the shorter summary form:

pvs

Note: You can also run pvcreate on individual partitions (e.g., /dev/sdb1) rather than whole disks. Using whole disks without a partition table is acceptable for dedicated LVM storage.

Step 3: Create a Volume Group with vgcreate

A Volume Group (VG) is a storage pool made up of one or more Physical Volumes. Logical Volumes are carved out of this pool. Create a VG named datavg from both physical volumes:

vgcreate datavg /dev/sdb /dev/sdc

Expected output:

  Volume group "datavg" successfully created

Inspect the volume group:

vgdisplay datavg

Key fields to note in vgdisplay output:

  • VG Size — total usable space in the group
  • PE Size — Physical Extent size (default 4 MiB); this is the minimum allocation unit
  • Free PE / Size — how much space remains unallocated

Step 4: Create Logical Volumes with lvcreate

With a VG in place, create Logical Volumes (LVs). LVs behave like block devices and can be formatted with any file system. Create a 15 GB LV named datalv inside datavg:

lvcreate -L 15G -n datalv datavg

Alternatively, use a percentage of the total VG space:

lvcreate -l 80%VG -n datalv datavg

Verify the logical volume:

lvdisplay /dev/datavg/datalv

The LV is now available at /dev/datavg/datalv or equivalently via the device mapper path /dev/mapper/datavg-datalv.

Step 5: Format and Mount the Logical Volume

Format the LV with XFS (the default file system on RHEL 7) or ext4:

# XFS (recommended for RHEL 7)
mkfs.xfs /dev/datavg/datalv

# Alternatively, ext4
mkfs.ext4 /dev/datavg/datalv

Create a mount point and mount the volume:

mkdir -p /mnt/data
mount /dev/datavg/datalv /mnt/data

Verify it is mounted:

df -hT /mnt/data

Step 6: Persist the Mount in /etc/fstab

To mount the LV automatically at boot, add an entry to /etc/fstab. Using the device mapper path or the LV path directly is fine, but using the UUID is the most robust approach:

blkid /dev/datavg/datalv

Sample output:

/dev/datavg/datalv: UUID="a1b2c3d4-e5f6-7890-abcd-ef1234567890" TYPE="xfs"

Add the following line to /etc/fstab:

UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890  /mnt/data  xfs  defaults  0  0

Test the fstab entry without rebooting:

umount /mnt/data
mount -a
df -hT /mnt/data

Step 7: Extend a Logical Volume Online

One of LVM’s greatest strengths is the ability to grow file systems while they are mounted and in use. To extend datalv by 5 GB:

lvextend -L +5G /dev/datavg/datalv

After extending the LV, the file system must also be grown to use the new space.

For XFS (can be done while mounted):

xfs_growfs /mnt/data

For ext4 (can also be done while mounted on RHEL 7):

resize2fs /dev/datavg/datalv

Confirm the new size:

df -hT /mnt/data

You can also combine the LV extension and file system resize into a single command with the -r flag:

lvextend -L +5G -r /dev/datavg/datalv

Step 8: Add a New Physical Volume to Expand the Volume Group

If the VG is running low on free space, add a new disk. Initialize it as a PV and add it to the existing VG:

pvcreate /dev/sdd
vgextend datavg /dev/sdd

Verify the VG now has additional free space:

vgs datavg

This additional capacity is immediately available for extending existing LVs or creating new ones, with no downtime required.

Step 9: Create LVM Snapshots for Backups

LVM snapshots create a point-in-time, copy-on-write view of a logical volume. They are ideal for taking consistent backups of live file systems.

Create a 2 GB snapshot of datalv:

lvcreate -L 2G -s -n datalv_snap /dev/datavg/datalv

Mount the snapshot read-only to browse or back up its contents:

mkdir -p /mnt/snapshot
mount -o ro /dev/datavg/datalv_snap /mnt/snapshot

Use rsync or tar to back up from the snapshot:

rsync -av /mnt/snapshot/ /backup/data-$(date +%F)/

After the backup is complete, unmount and remove the snapshot:

umount /mnt/snapshot
lvremove /dev/datavg/datalv_snap

Important: A snapshot that fills up (exceeds its allocated size) will become invalid. Monitor snapshot usage with lvs and allocate sufficient space for the expected rate of change during the backup window.

Step 10: Thin Provisioning with LVM

Thin provisioning allows you to allocate more storage to LVs than the VG physically contains, with actual space consumed only as data is written. This is useful in virtualization and development environments.

Create a thin pool named thinpool using 80% of the VG:

lvcreate -l 80%VG --thinpool thinpool datavg

Create a thin LV from the pool, provisioning 50 GB even if the pool is smaller:

lvcreate -V 50G --thin -n thin_data datavg/thinpool

Format and mount as normal:

mkfs.xfs /dev/datavg/thin_data
mount /dev/datavg/thin_data /mnt/thin_data

Monitor thin pool usage:

lvs -a datavg

Conclusion

LVM on RHEL 7 provides a flexible, enterprise-grade storage management layer that goes far beyond what traditional partitioning can offer. By mastering pvcreate, vgcreate, and lvcreate, you gain the ability to carve up storage pools with precision. The ability to extend volumes online with lvextend and xfs_growfs, expand volume groups with vgextend, and create instantaneous snapshots for backup workflows makes LVM indispensable in production environments. Whether you are managing a single server or a large-scale infrastructure, LVM gives you the control and flexibility to respond to changing storage demands without downtime or data risk.