Skip to main content
LVM (Logical Volume Manager) provides a flexible, abstraction-based storage layer on Linux. Instead of partitioning disks directly, LVM lets you pool storage from multiple devices and allocate space dynamically. This improves scalability, snapshotting, resizing, and overall storage management.

LVM Architecture Overview

LVM provides three layers of abstraction: Physical Volumes (PV), Volume Groups (VG), and Logical Volumes (LV).

Physical Volume (PV)

Physical Volume

A Physical Volume is a disk or partition prepared for use by LVM. It represents the lowest LVM layer, created from real storage devices (e.g., /dev/sda, RAID LUNs).
Key points:
  • Created with pvcreate
  • Forms the building blocks of a VG
  • Can be added or removed to adjust total capacity
# Create a physical volume
pvcreate /dev/sdb

# List physical volumes
pvs
pvdisplay

Volume Group (VG)

Volume Group

A Volume Group aggregates one or more PVs into a single storage pool. This pool behaves like one large virtual disk.
Key points:
  • Created with vgcreate
  • Expands by adding more PVs
  • Space is allocated to LVs from the VG
# Create a volume group
vgcreate my_vg /dev/sdb /dev/sdc

# Extend a volume group
vgextend my_vg /dev/sdd

# List volume groups
vgs
vgdisplay

Logical Volume (LV)

Logical Volume

A Logical Volume is carved out of a Volume Group and behaves like a virtual partition. Filesystems, swap, containers, or VMs are placed on LVs.
Key points:
  • Created with lvcreate
  • Can be resized dynamically
  • Supports snapshots and thin provisioning
# Create a logical volume
lvcreate -L 50G -n my_lv my_vg

# Extend a logical volume
lvextend -L +20G /dev/my_vg/my_lv

# List logical volumes
lvs
lvdisplay

LVM Architecture Diagram

The following diagram illustrates how physical devices flow through LVM layers:
  • 🟨 Physical Device (PD) β€” Actual disk hardware
  • 🟦 Physical Volume (PV) β€” LVM-initialized disk
  • 🟧 Volume Group (VG) β€” Storage pool
  • 🟩 Logical Volume (LV) β€” Virtual partition

Common LVM Operations

Creating a Complete LVM Setup

1

Create Physical Volumes

Initialize disks for LVM use
pvcreate /dev/sdb /dev/sdc /dev/sdd
2

Create Volume Group

Pool physical volumes together
vgcreate data_vg /dev/sdb /dev/sdc /dev/sdd
3

Create Logical Volumes

Allocate space from the volume group
lvcreate -L 100G -n database_lv data_vg
lvcreate -L 50G -n logs_lv data_vg
4

Create Filesystems

Format and mount the logical volumes
mkfs.xfs /dev/data_vg/database_lv
mkfs.xfs /dev/data_vg/logs_lv
mount /dev/data_vg/database_lv /var/lib/mysql
mount /dev/data_vg/logs_lv /var/log

Resizing Logical Volumes

LVM allows online resizing β€” you can grow volumes while they’re mounted and in use. See Online Storage Resize for details.
# Extend logical volume
lvextend -L +50G /dev/data_vg/database_lv

# Grow filesystem (XFS)
xfs_growfs /var/lib/mysql

# Grow filesystem (ext4)
resize2fs /dev/data_vg/database_lv

LVM Snapshots

Create point-in-time snapshots for backups or testing:
# Create snapshot
lvcreate -L 10G -s -n database_snap /dev/data_vg/database_lv

# Mount snapshot for backup
mount -o ro /dev/data_vg/database_snap /mnt/backup

# Remove snapshot after backup
umount /mnt/backup
lvremove /dev/data_vg/database_snap
Snapshots consume space from the volume group as changes occur. Monitor snapshot usage to prevent them from filling up.

Troubleshooting

Visualize the Storage Stack

Use lsblk to see the complete storage hierarchy:
lsblk -e7 -o NAME,HCTL,SIZE,TYPE,FSTYPE,MOUNTPOINT
This shows:
FC path (sdX)
    ↓
multipath device (mpathX)
    ↓
LVM logical volume (LV)
    ↓
filesystem (ext4/xfs)
    ↓
mountpoint (/mnt/mpathX)

Common Issues

# Scan for volume groups
vgscan

# Activate volume group
vgchange -ay my_vg
# Summary view
vgs

# Detailed view
vgdisplay my_vg
# Backup metadata
vgcfgbackup my_vg

# Restore if needed
vgcfgrestore my_vg

Best Practices

Use Descriptive Names

Name VGs and LVs based on their purpose (e.g., data_vg, database_lv)

Leave Space Free

Keep 10-20% of VG space unallocated for snapshots and growth

Monitor Usage

Regularly check vgs and lvs output for capacity planning

Backup Metadata

Periodically run vgcfgbackup to save LVM configuration

Use XFS for Large Volumes

XFS performs better than ext4 for large filesystems

Document Your Layout

Keep records of PV→VG→LV mappings and purposes

Quick Reference

TaskCommand
List PVspvs, pvdisplay
List VGsvgs, vgdisplay
List LVslvs, lvdisplay
Create PVpvcreate /dev/sdX
Create VGvgcreate my_vg /dev/sdX
Create LVlvcreate -L 50G -n my_lv my_vg
Extend VGvgextend my_vg /dev/sdY
Extend LVlvextend -L +20G /dev/my_vg/my_lv
Remove LVlvremove /dev/my_vg/my_lv
Remove VGvgremove my_vg
Remove PVpvremove /dev/sdX
For SAN storage environments, combine LVM with multipath for redundancy. See Online Storage Resize for production expansion procedures.

Build docs developers (and LLMs) love