🔧 LVM Management

Storage Series: Part 1 — LVM Basics  |  Part 2 — LVM Management  |  Part 3 — LVM Snapshots  |  Part 4 — RAID Overview

Managing LVM in Production

Once your LVM infrastructure is in place, day-to-day management means growing LVs as filesystems fill, moving data between physical disks, extending volume groups with new storage, and occasionally reducing volumes when storage needs change. Most of these operations happen online — no downtime required.

This page covers the operations you will use most frequently: lvextend, lvreduce, lvresize, vgextend, pvmove, and the filesystem resize commands that must accompany LV changes.

Examples

1
Extend a Logical Volume — lvextend

Growing an LV is the most common LVM operation — always online, always safe:

# Extend by an additional amount
sudo lvextend -L +50G /dev/vg_data/lv_home

# Extend to a specific total size
sudo lvextend -L 300G /dev/vg_data/lv_home

# Extend using all remaining free space in the VG
sudo lvextend -l +100%FREE /dev/vg_data/lv_home

# Extend AND resize the filesystem in one command (-r flag)
sudo lvextend -L +50G -r /dev/vg_data/lv_home

# Verify
sudo lvs /dev/vg_data/lv_home
df -h /home
The -r flag is your friend. lvextend -r extends the LV AND automatically resizes the filesystem in a single command — it detects whether the filesystem is ext4 or XFS and runs the appropriate resize tool. Use it and skip the separate resize2fs / xfs_growfs step.
💡 Always check free space first: sudo vgs shows VFree — how much space is available in the VG to extend into. You cannot extend an LV beyond the VG's free space without first adding a new PV.
2
Resize Filesystems After Extending

If you extended without -r, resize the filesystem manually. The method depends on the filesystem type:

### ext4 — resize2fs (works mounted or unmounted) ###

# Extend the LV first
sudo lvextend -L +100G /dev/vg_data/lv_home

# Resize ext4 to fill the LV (no size needed — fills automatically)
sudo resize2fs /dev/vg_data/lv_home

# Verify
df -h /home


### XFS — xfs_growfs (must be mounted) ###

# Extend the LV first
sudo lvextend -L +100G /dev/vg_data/lv_var

# Grow XFS filesystem — use the mount point, not the device
sudo xfs_growfs /var

# Verify
df -h /var
ext4 vs XFS resize: resize2fs takes the device path and works whether mounted or not. xfs_growfs takes the mount point and requires the filesystem to be mounted. XFS cannot be shrunk — only grown. ext4 can be shrunk but requires unmounting first.
3
Reduce a Logical Volume — lvreduce

Shrinking an LV is more dangerous than extending — the filesystem must be shrunk first, then the LV. Only ext4 supports shrinking; XFS cannot be reduced:

### ext4 ONLY — XFS cannot be shrunk ###

# Step 1: Unmount the filesystem
sudo umount /home

# Step 2: Check filesystem integrity first
sudo e2fsck -f /dev/vg_data/lv_home

# Step 3: Shrink the filesystem FIRST (before the LV)
sudo resize2fs /dev/vg_data/lv_home 80G

# Step 4: Shrink the LV to match
sudo lvreduce -L 80G /dev/vg_data/lv_home

# Step 5: Remount
sudo mount /dev/vg_data/lv_home /home

# Step 6: Verify
df -h /home
⚠️ Shrink the filesystem BEFORE the LV — always. If you shrink the LV first, you truncate the filesystem and will corrupt all data on it. The safe order is:
1. Unmount → 2. e2fsck → 3. resize2fs (smaller) → 4. lvreduce → 5. remount.
Take a snapshot or backup before reducing. This operation cannot be undone.
💡 lvresize combines extend and reduce: lvresize is the general-purpose command that can both grow and shrink. Use lvresize -r -L 80G /dev/vg_data/lv_home and the -r flag handles filesystem resize automatically — but it still requires unmounting for shrink operations.
4
Extend a Volume Group — vgextend

When a VG runs low on free space, add a new physical disk to it:

# Step 1: Confirm the VG is running low
sudo vgs
# VFree is small — time to add storage

# Step 2: Initialize the new disk as a PV
sudo pvcreate /dev/sde

# Step 3: Add it to the existing VG
sudo vgextend vg_data /dev/sde

# Step 4: Verify VG now has more free space
sudo vgs
sudo pvs   # shows new PV is now part of vg_data

# Step 5: Now extend LVs as needed
sudo lvextend -L +200G -r /dev/vg_data/lv_home
vgs before and after vgextend:
Before: VG #PV #LV #SN Attr VSize VFree vg_data 2 3 0 wz--n- 1.80t 12.00g After: VG #PV #LV #SN Attr VSize VFree vg_data 3 3 0 wz--n- 2.70t 912.00g
5
Move Data Between Disks — pvmove

pvmove migrates data off a physical volume onto other PVs in the same VG — online, while the filesystem is mounted and in use. Essential for replacing a failing disk without downtime:

# Move ALL data off /dev/sdb to other PVs in the VG
sudo pvmove /dev/sdb

# Move data from one specific PV to another specific PV
sudo pvmove /dev/sdb /dev/sde

# Move data from a specific LV on a PV
sudo pvmove -n lv_home /dev/sdb

# Run in background (large volumes take time)
sudo pvmove -b /dev/sdb

# Monitor progress of a background pvmove
sudo lvs -a | grep pvmove
sudo watch -n5 'sudo pvs'

# After pvmove completes — remove the PV from the VG
sudo vgreduce vg_data /dev/sdb

# Remove the PV label (disk is now free)
sudo pvremove /dev/sdb
pvmove progress output:
/dev/sdb: Moved: 12.45% /dev/sdb: Moved: 28.91% /dev/sdb: Moved: 47.33% /dev/sdb: Moved: 68.77% /dev/sdb: Moved: 89.12% /dev/sdb: Moved: 100.00%
💡 Disk replacement workflow: When a disk is failing (SMART warnings, errors in dmesg): add the replacement disk as a new PV, vgextend it into the VG, then pvmove data off the failing disk, then vgreduce and pvremove the bad disk. Zero downtime, zero data loss.
6
Rename VGs and LVs

Renaming LVM objects — useful when server roles change or naming conventions need to be corrected:

# Rename a Logical Volume
sudo lvrename vg_data lv_home lv_users

# Or specify full paths
sudo lvrename /dev/vg_data/lv_home /dev/vg_data/lv_users

# Rename a Volume Group
sudo vgrename vg_data vg_production

# After renaming VG — update /etc/fstab entries
sudo vi /etc/fstab
# Change /dev/vg_data/... to /dev/vg_production/...

# Verify new names
sudo vgs
sudo lvs
⚠️ Update fstab after renaming. Renaming a VG or LV changes the device path. If /etc/fstab still references the old name, the next reboot will fail to mount those filesystems. Update fstab immediately after renaming and test with sudo mount -a.
7
Check LV and VG Health

Regular health checks to catch problems before they become outages:

# Quick overall status
sudo pvs && sudo vgs && sudo lvs

# Check for any partial or failed LVs
sudo lvs -a | grep -v "-wi-ao"

# Detailed attribute flags — look for anything not 'a' (active)
sudo lvs -o name,vgname,attr,size,pool_lv

# Check PV for missing or duplicate UUIDs
sudo pvscan

# Check VG consistency
sudo vgck vg_data

# Scan all block devices for LVM metadata
sudo lvscan

# Backup LVM metadata (do this regularly)
sudo vgcfgbackup vg_data
# Saved to /etc/lvm/backup/vg_data

# List metadata backups
ls -la /etc/lvm/backup/
ls -la /etc/lvm/archive/
💡 LVM metadata backups are automatic — every LVM command that modifies the VG writes a backup to /etc/lvm/archive/. You can restore a VG from these backups with vgcfgrestore if metadata is corrupted. Keep these files safe.
8
Emergency — Disk Failure Recovery

When a PV disk fails and the VG is in a degraded state:

# VG shows as partial — a PV is missing
sudo vgs
# Attr shows 'p' (partial) instead of normal

# Activate VG in partial mode (access surviving LVs)
sudo vgchange -a y --partial vg_data

# Identify which PV is missing
sudo pvs
# Missing PV shows as [unknown]

# If replacement disk is available — add it
sudo pvcreate /dev/sdf
sudo vgextend vg_data /dev/sdf

# Remove the missing PV record from the VG
sudo vgreduce --removemissing vg_data

# If VG metadata backup exists — restore
sudo vgcfgrestore -f /etc/lvm/archive/vg_data_00001.vg vg_data

# Check filesystem integrity after recovery
sudo e2fsck -f /dev/vg_data/lv_home
⚠️ Data on the failed PV is lost unless you had RAID under LVM or LVM mirroring configured. LVM striping (the default) spreads data across PVs — losing one PV means losing data on all LVs that used it. This is why LVM and hardware RAID or LVM mirroring are often combined in production.

Quick Reference

CommandWhat it does
lvextend -L +50G -r /dev/vg/lvExtend LV by 50G and resize filesystem
lvextend -l +100%FREE -r /dev/vg/lvUse all remaining VG space
lvreduce -L 80G /dev/vg/lvShrink LV to 80G (filesystem first!)
lvresize -r -L 200G /dev/vg/lvResize LV and filesystem to 200G
resize2fs /dev/vg/lvGrow ext4 to fill LV
xfs_growfs /mountpointGrow XFS to fill LV (mounted)
vgextend vgname /dev/sdXAdd new PV to existing VG
vgreduce vgname /dev/sdXRemove a PV from a VG
pvmove /dev/sdXMove all data off a PV
pvmove -b /dev/sdXMove data in background
lvrename vg oldlv newlvRename a Logical Volume
vgrename oldvg newvgRename a Volume Group
vgcfgbackup vgnameBackup VG metadata manually
vgcfgrestore vgnameRestore VG from metadata backup
vgchange -a y --partial vgActivate partial VG after disk failure

Extend LV Workflow — The Safe Sequence

StepCommandNotes
1. Check free spacesudo vgsConfirm VFree is sufficient
2. Extend LV + FSsudo lvextend -L +NG -r /dev/vg/lv-r handles filesystem resize
3. Verifydf -h /mountpointConfirm new size visible

Reduce LV Workflow — The Safe Sequence (ext4 only)

StepCommandNotes
1. Unmountsudo umount /mountpointRequired for shrink
2. Check filesystemsudo e2fsck -f /dev/vg/lvFix errors before resize
3. Shrink filesystemsudo resize2fs /dev/vg/lv NGMust be smaller than LV target
4. Shrink LVsudo lvreduce -L NG /dev/vg/lvMatch or slightly larger than FS
5. Remountsudo mount /dev/vg/lv /mountpointVerify clean mount
6. Verifydf -h /mountpointConfirm new size

← Back to Storage Index ↑ Back to EXPANDED