Skip to content

LVM: Logical Volume Management from Scratch

Build a full PV → VG → LV stack from a raw disk, then extend it live — the exact workflow behind 'the disk is full' tickets that don't need downtime.

LVM2ext4xfs
2 min readIntermediate
Lab time: 30-40 min
RR

Ranjith R

Linux SysAdmin & Cloud Engineer

Published July 1, 2026Updated July 6, 2026
Share
Section 01

Prerequisites

  • A Linux VM with a spare, unused disk (or the ability to attach one — a second virtual disk in VirtualBox/VMware/cloud console works fine)
  • Root access
  • lvm2 package installed (preinstalled on most server distros)
Section 02

What You'll Learn

  • Create physical volumes, volume groups, and logical volumes from raw block devices
  • Extend a mounted logical volume and its filesystem live, without unmounting
  • Explain the PV → VG → LV relationship and why LVM decouples storage from partitions
  • Recognize the recovery options when a volume group loses a physical volume
Section 03

Theory

Traditional partitioning ties a filesystem directly to a fixed-size slice of one physical disk — growing it later means the free space has to be physically adjacent, and spanning multiple disks isn't possible at all. LVM inserts an abstraction layer with three levels:

LayerWhat it is
Physical Volume (PV)A raw disk or partition, initialized for LVM to use
Volume Group (VG)A storage pool combining one or more PVs into a single space
Logical Volume (LV)A virtual "partition" carved from a VG, formatted with a filesystem

Because an LV draws from the VG's pooled space rather than a fixed disk region, you can grow an LV by simply adding more PVs to its VG — the filesystem doesn't need to know or care which physical disk the extra space actually came from.

Section 04

Architecture

Two physical disks pooled into one volume group, carved into two independently-sized logical volumes

Section 05

Hands-On Lab

Assumes a spare disk attached as /dev/sdb — confirm with lsblk first and substitute the real device name.

# 1. Create the physical volume
sudo pvcreate /dev/sdb
sudo pvs                              # confirm it's recognized

# 2. Create a volume group from it
sudo vgcreate vg_data /dev/sdb
sudo vgs

# 3. Create a 5G logical volume inside the volume group
sudo lvcreate -L 5G -n lv_web vg_data
sudo lvs

# 4. Format and mount it
sudo mkfs.ext4 /dev/vg_data/lv_web
sudo mkdir -p /mnt/web
sudo mount /dev/vg_data/lv_web /mnt/web
df -h /mnt/web

# 5. Extend it live — grow the LV by 2G, then grow the filesystem to match
sudo lvextend -L +2G /dev/vg_data/lv_web
sudo resize2fs /dev/vg_data/lv_web    # ext4; use 'sudo xfs_growfs /mnt/web' for XFS
df -h /mnt/web                        # confirm the new size is visible, still mounted
Section 07

Best Practices

Leave free space in the volume group

Don't allocate 100% of a VG's capacity to LVs immediately — keeping some free PE (physical extents) unallocated lets you extend an LV instantly later without adding a new disk.

Snapshot before risky changes

lvcreate -L 1G -s -n lv_web_snap /dev/vg_data/lv_web creates a point-in-time snapshot you can roll back to — take one before a risky in-place upgrade or migration.
Section 08

Common Mistakes

Extending the LV but forgetting to grow the filesystem

lvextend resizes the block device, not the filesystem sitting on it — the extra space is invisible to df until you also run resize2fs (ext4) or xfs_growfs (XFS, note: takes a mount point, not a device path).

Trying to shrink an XFS filesystem

XFS supports growing but has no shrink operation at all — if you need a smaller filesystem, the only path is backup → recreate smaller → restore. Plan XFS logical volume sizes conservatively for this reason; ext4 does support shrinking (offline, unmounted).
Section 09

Troubleshooting

"Insufficient free extents" on lvextend: the volume group itself is out of free space — check with vgs (the VFree column) and either add another physical volume with vgextend or free space from another LV first.

A physical volume fails/disappears from a VG: if the VG has no redundancy (a single PV, or PVs without an LVM RAID setup), data on that PV is lost — LVM alone provides no redundancy by default. vgreduce --removemissing vg_datacan bring the VG back online minus the failed PV's extents, but any LV data that lived there is gone; this is why LVM is not a substitute for RAID or backups.

Section 10

Interview Questions

Extend the LV first: `lvextend -L +10G /dev/vgdata/lvdata`. Then grow the filesystem live — for ext4: `resize2fs /dev/vgdata/lvdata`; for XFS: `xfs_growfs /mount/point` (XFS can only grow, never shrink, and must be referenced by mount point, not device). Both commands are safe on a mounted, in-use filesystem.
See all 21 Linux interview questions
Section 11

Cheat Sheet

Disk & Storage

df -hShow disk space usage for all mounted filesystems
lsblkList block devices and their mount points
mount /dev/sdb1 /mntMount a device to a directory
fdisk -lList partition tables on all disks
vgs / lvs / pvsList LVM volume groups / logical volumes / physical volumes
Get the full cheat sheet (with PDF download)
FAQ

Frequently Asked Questions

Yes — that's the core benefit of LVM. Run pvcreate on the new disk, then vgextend vg_data /dev/sdc to add it to the existing volume group, immediately increasing the pool any LV in that group can draw from.
Section 12

Summary

LVM pools one or more physical volumes into a volume group, then carves logical volumes from that pool — decoupling filesystem size from any single disk's physical boundaries. Extending storage live is a two-step process (grow the LV, then grow the filesystem), and LVM alone provides no redundancy, so pair it with RAID or backups for anything that matters.