LVM Logical Volume Manager on Linux VPS

LVM on Linux VPS — Disk Management Guide

October 3, 2026 · ~12 min read

LVM (Logical Volume Manager) is a disk management layer for Linux that lets you resize, move, and snapshot storage volumes on the fly — without reformatting or rebooting. Instead of fixed partitions carved directly from a raw disk, LVM introduces an abstraction layer between physical disks and filesystems, making storage far more flexible. For VPS environments where you often need to expand storage after the fact, LVM is an essential skill.

Understanding LVM Architecture

LVM works in three layers:

CommandPurposeExample
pvcreateInitialize a Physical Volumepvcreate /dev/sdb
vgcreateCreate a Volume Groupvgcreate vg_data /dev/sdb
lvcreateCreate a Logical Volumelvcreate -L 20G -n lv_data vg_data
lvextendGrow a Logical Volumelvextend -L +10G /dev/vg_data/lv_data
lvs / vgs / pvsShow statuslvs

1. Install LVM Tools

# Debian / Ubuntu
apt update && apt install lvm2 -y

# CentOS / AlmaLinux / Rocky
dnf install lvm2 -y

# Verify installation
lvm version
Note: Many VPS images ship with LVM pre-installed. Run pvs to check if any Physical Volumes already exist. No output means LVM is installed but not yet configured.

2. Initialize a New Disk as a Physical Volume

After attaching a new disk via your VPS control panel, it typically appears as /dev/sdb or /dev/vdb:

# List all disks
lsblk
fdisk -l

# Initialize the new disk as a PV
pvcreate /dev/sdb

# Verify
pvs
# Example output:
#   PV         VG   Fmt  Attr PSize  PFree
#   /dev/sdb        lvm2 ---  50.00g 50.00g

3. Create a Volume Group

# Create a VG named vg_data from /dev/sdb
vgcreate vg_data /dev/sdb

# Combine multiple disks into one VG
vgcreate vg_data /dev/sdb /dev/sdc

# Inspect the VG
vgs
# Output:
#   VG      #PV #LV #SN Attr   VSize   VFree
#   vg_data   1   0   0 wz--n- 50.00g 50.00g

vgdisplay vg_data

4. Create a Logical Volume and Format It

# Create a 20 GB LV named lv_data
lvcreate -L 20G -n lv_data vg_data

# Use all available free space in the VG
lvcreate -l 100%FREE -n lv_data vg_data

# Format as ext4
mkfs.ext4 /dev/vg_data/lv_data

# Or format as xfs (recommended for large files)
mkfs.xfs /dev/vg_data/lv_data

# Mount it
mkdir -p /mnt/data
mount /dev/vg_data/lv_data /mnt/data

# Persist the mount in /etc/fstab
echo '/dev/vg_data/lv_data /mnt/data ext4 defaults 0 2' >> /etc/fstab

# Test fstab
mount -a && df -h /mnt/data

5. Extend a Logical Volume Online (No Unmount Needed)

This is LVM's killer feature — grow storage while the server is running:

# Grow the LV by 10 GB
lvextend -L +10G /dev/vg_data/lv_data

# Use all remaining free space
lvextend -l +100%FREE /dev/vg_data/lv_data

# Grow the ext4 filesystem to match the LV
resize2fs /dev/vg_data/lv_data

# For xfs (filesystem must be mounted)
xfs_growfs /mnt/data

# Confirm
df -h /mnt/data
Tip: Use lvextend -r to resize the filesystem in the same step: lvextend -L +10G -r /dev/vg_data/lv_data — no need to run resize2fs separately for ext4.

6. Add a New Disk to an Existing Volume Group

# Initialize the new disk
pvcreate /dev/sdc

# Add it to the existing VG
vgextend vg_data /dev/sdc

# Confirm the free space increased
vgs vg_data

# Extend the LV to use the new space
lvextend -l +100%FREE /dev/vg_data/lv_data
resize2fs /dev/vg_data/lv_data

7. LVM Snapshots — Safe Point-in-Time Backups

Snapshots freeze the state of an LV at a specific moment. Use them before risky operations like database upgrades or OS updates:

# Create a 5 GB snapshot (stores the diff)
lvcreate -L 5G -s -n lv_data_snap /dev/vg_data/lv_data

# Check snapshot status
lvs
# lv_data_snap will show Attr: swi-a-s---

# Mount the snapshot read-only
mkdir -p /mnt/snap
mount -o ro /dev/vg_data/lv_data_snap /mnt/snap

# Remove the snapshot when done
umount /mnt/snap
lvremove /dev/vg_data/lv_data_snap
Tip: Snapshots use copy-on-write — the more writes happen after the snapshot, the faster it fills up. Size it at least 10–20% of the original LV to avoid snapshot overflow invalidating your backup.

8. Restore from a Snapshot

# Unmount the live LV first (if it's not the root FS)
umount /mnt/data

# Merge the snapshot back (reverts to snapshot state)
lvconvert --merge /dev/vg_data/lv_data_snap

# Reboot to apply the merge (required for root filesystems)
reboot

9. Migrate Data Between Physical Volumes (pvmove)

# Check which PV holds the data
pvs -o+pv_used

# Move all data off /dev/sdb onto /dev/sdc
pvmove /dev/sdb /dev/sdc

# Move only a specific LV
pvmove -n /dev/vg_data/lv_data /dev/sdb /dev/sdc

# Remove the old PV from the VG
vgreduce vg_data /dev/sdb

# Wipe the PV label
pvremove /dev/sdb

Verify LVM Is Working Correctly

# Check PV, VG, and LV status
pvs
vgs
lvs

# Detailed view
pvdisplay
vgdisplay
lvdisplay

# Check filesystem on the LV
df -h /mnt/data
mount | grep lv_data

# Inspect device mapper entries
ls -la /dev/mapper/
ls -la /dev/vg_data/

# Validate fstab
findmnt --verify --fstab
Tip: Run vgscan && lvscan to force LVM to rescan all PVs, VGs, and LVs. Useful after attaching a new disk or restoring from a backup image.

Common Errors and Fixes

Error: "Can't open /dev/sdb exclusively"

The disk is in use or still has a stale partition table lock. Unmount it and reload the partition table first.

# Check if the disk is mounted
lsof /dev/sdb
umount /dev/sdb

# Reload the partition table
partprobe /dev/sdb

# Retry pvcreate
pvcreate /dev/sdb

Error: "Insufficient free space" during lvcreate

The VG doesn't have enough free space. Check with vgs and add more disks if needed.

# Check free space in the VG
vgs
# VFree column shows available space

# Add a new disk to the VG
pvcreate /dev/sdc
vgextend vg_data /dev/sdc

Error: "resize2fs: Device or resource busy"

You can extend a mounted ext4 volume, but shrinking requires unmounting first.

# Extending while mounted (safe)
lvextend -L +10G /dev/vg_data/lv_data
resize2fs /dev/vg_data/lv_data

# Shrinking requires unmounting
umount /mnt/data
e2fsck -f /dev/vg_data/lv_data
resize2fs /dev/vg_data/lv_data 15G
lvreduce -L 15G /dev/vg_data/lv_data
mount /dev/vg_data/lv_data /mnt/data

Error: "Volume group not found" after reboot

The LVM daemon didn't scan the VG at boot. Enable the services and update initramfs.

# Enable LVM services
systemctl enable lvm2-lvmetad.service
systemctl enable lvm2-monitor.service

# Rebuild initramfs (Debian/Ubuntu)
update-initramfs -u

# Rebuild initramfs (RHEL/CentOS)
dracut --force

reboot
vgs

Error: "Snapshot LV is full"

Too many writes occurred after the snapshot. A full snapshot becomes invalid. Extend it proactively or delete and recreate it.

# Check snapshot usage percentage
lvs -o lv_name,snap_percent /dev/vg_data/lv_data_snap

# Extend the snapshot before it fills up
lvextend -L +2G /dev/vg_data/lv_data_snap

# If it's already invalid, delete and recreate
lvremove /dev/vg_data/lv_data_snap
lvcreate -L 10G -s -n lv_data_snap /dev/vg_data/lv_data

Frequently Asked Questions

How is LVM different from regular partitioning?

Traditional partitions (MBR/GPT) are fixed in size and require downtime to resize. LVM adds an abstraction layer that enables online resizing, combining multiple disks into one pool, snapshots, and live data migration — all without stopping the server. For any VPS where storage grows over time, LVM is far superior to static partitioning.

Can I use LVM with SSD or NVMe disks on a VPS?

Yes. LVM works with any block device — HDD, SSD, NVMe, or virtual disks (vda, vdb) on a VPS. The LVM abstraction layer has very low overhead (under 1%), so there's no meaningful performance difference compared to mounting the disk directly.

My VPS root filesystem is already on LVM. Can I expand it?

Yes. First expand the virtual disk from your VPS control panel. Then use growpart to resize the PV partition, followed by pvresize, lvextend, and resize2fs in order. Some VPS providers include automated tools that handle this in one click.