Overview
Logical Volume Management (LVM) provides a flexible method of managing storage on Linux systems. Instead of tying filesystems directly to physical disks, LVM introduces abstraction layers that allow administrators the flexibility to resize, migrate, encrypt, and scale storage with minimal downtime.
This guide walks through:
- Purpose and best practices for using LVMs
- Scalability advantages
- Creating Physical Volumes (PVs)
- Creating and staging Volume Groups (VGs)
- Creating Logical Volumes (LVs), encryption, formatting, and mounting
- Expanding storage by adding drives
- Extending Logical Volumes safely
1. Purpose of LVM and Best Practices
Why Use LVM?
Traditional partitioning binds directly to disks. LVM introduces additional flexibility by separating physical storage, allowing for storage pools, and creating usable filesystems which allows system administrators to:
- Expand storage without rebuilding systems
- Snapshot volumes
- Migrate storage between disks
- Support encryption layers
- Improve disaster recovery workflows.
2. Scalability Advantages
LVM enables horizontal scaling of storage:
- Addition of disks without downtime
- Extend filesystems online
- Aggregate multiple drives into one logical pool
- Advantageous when using virtual machines that have a per-disk size limitation.
- Move data transparently between disks
3. Creating Physical Volumes (PVs)
A Physical Volume (PV) is the lowest storage layer in Linux Logical Volume Management. It represents the actual physical storage device that LVM can use. A physical volume can be created from an entire disk (/dev/sdb) or from a disk partition (/dev/sdb1)
Identify Drives
lsblk
sda 100G
sdb 500G
sdc 500G
Create Physical Volumes
Initialize applicable disks for LVM (additional drives can be added later if needed):
pvcreate /dev/sdb
pvcreate /dev/sdc
#Verify creation by running pvs
pvs
Best Practices:
- Always confirm disks are unused before initialization.
- Use whole disks unless partitioning is required by policy.
4. Create Volume Groups (VGs)
A Volume Group aggregates physical volumes into a singular storage pool. Logically, this combines all of your hard drive space into a singular volume. Additional drives can be added to the volume group at a later time.
Create Volume Group with name “vg_data” and Verify Creation:
vgcreate vg_data /dev/sdb /dev/sdc
#verify creation
vgs
5. Creating Logical Volumes (LVs)
Logical Volumes act like traditional partitions. After the size has been determined and the LVM is created, additional layers (such as encryption, vdo, or the filesystem) can be added on.
In the below example, we will create three Logical volumes for user data, backup data, and application data.
Create Logical Volumes for the three LVMs (lv_user, lv_backup, and lv_app)
#Create 100G User data LVM
lvcreate -L 100G -n lv_user vg_data
#Create 300G Backup data LVM
lvcreate -L 300G -n lv_backup vg_data
#Create Application data LVM with remaining free space
lvcreate -l 100%FREE -n lv_app vg_data
#Verify creation
lvs
Format the Filesystem using XFS
mkfs.xfs /dev/vg_data/lv_app
mkfs.xfs /dev/vg_data/lv_user
mkfs.xfs /dev/vg_data/lv_backup
Create Mount points and Retrieve unique identifiers
mkdir /app-data ; mkdir /user-data ; mkdir /backup-data
blkid #Look for the UUID=<uuid> line of each line above
Edit the /etc/fstab file and add lines for each volume
#Note, remove all quotes from the UUID when adding to the fstab
UUID=<uuid> /user-data xfs defaults 0 0
UUID=<uuid> /backup-data xfs defaults 0 0
UUID=<uuid> /app-data xfs defaults 0 0
Reload system daemon, mount, and relabel SELinux contexts
systemctl daemon-reload
#Mount everything from the fstab
mount -av
#Verify mounts
df -h
#Relabel SELinux contexts if applicable
restorecon -Rv /app-data
restorecon -Rv /user-data
restorecon -Rv /backup-data
6. Adding Additional Drives (Scaling Storage)
When new storage drives are added to the system, follow the below instructions to add the drives to the pool.
Step 1 – Create the Physical Volume
pvcreate /dev/sdd #New Drive
Step 2 – Extend the Volume Group
vgextend vg_data /dev/sdd
#Verify
vgs
7. Extending Logical Volumes
If the storage pool has enough free space, individual logical volumes can be extended to provide additional space using the below instructions.
Extend the Logical Volume
Increase the application data LVM by a specific size:
lvextend -L +100G /dev/vg_data/lv_app
Use all remaining free space to extend the backup data LVM:
lvextend -l +100%FREE /dev/vg_data/lv_backup
Grow Filesystem (Online)
This step is used to increase the xfs filesystem size in a live environment after additional storage has been allocated.
xfs_growfs /app-data
xfs_growfs /backup-data
#Verify new sizes with
df -h
Summary
LVM is a foundational Enterprise Linux skill that enables scalable, resilient, and secure storage architectures. By separating physical storage from logical allocation, system administrators gain flexibility for growth, maintenance, and disaster recovery.
Key Workflow:
- Create PV on all applicable drives
- Create a VG to contain all application drives
- Create LV for each desired partition
- Format filesystem on each LV
- Mount and make persistent
- Extend/Grow as needed