Operations 10 min read

Master LVM on Linux: Create, Expand, and Shrink Logical Volumes Step‑by‑Step

This guide explains the fundamentals of Linux Logical Volume Manager (LVM), covering key concepts such as physical volumes, volume groups, and logical volumes, and provides detailed, command‑line instructions for creating, extending, reducing, and deleting logical volumes on a VMware virtual machine.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master LVM on Linux: Create, Expand, and Shrink Logical Volumes Step‑by‑Step

Overview

The Logical Volume Manager (LVM) is a Linux storage subsystem that enables dynamic resizing of disk partitions, solving the problem of unpredictable storage growth in production environments.

Basic Concepts

LVM consists of three core components:

Physical Volume (PV) : a raw disk or RAID array.

Volume Group (VG) : a pool of one or more PVs.

Logical Volume (LV) : a virtual block device allocated from a VG, built from Physical Extents (PEs), the smallest allocatable unit.

Each LV is presented under /dev/<vg_name>/<lv_name>, allowing applications to use storage without knowing the underlying disks.

Practical Operations

1. Create Physical Volumes and a Volume Group

Assuming two new 20 GB disks ( /dev/sdb and /dev/sdc) are attached to a VMware VM, initialize them for LVM: pvcreate /dev/sdb /dev/sdc Then create a volume group named storage that aggregates the two disks: vgcreate storage /dev/sdb /dev/sdc Verify the VG status: vgdisplay The output shows a PE size of 4 MiB and a total of 10 238 PEs (≈40 GiB).

LVM concepts diagram
LVM concepts diagram

2. Create a Logical Volume

Allocate a 201 MiB LV named kdyzm_lv from the storage VG. LVM rounds the size to a whole number of PEs, so the LV becomes 204 MiB (51 PEs):

lvcreate -n kdyzm_lv -L 201M storage

3. Format and Mount the LV

Use ext4 (preferred over XFS for LVM) and add the mount point to /etc/fstab for persistence:

mkfs.ext4 /dev/storage/kdyzm_lv
mount /dev/storage/kdyzm_lv /kdyzm_lv

4. Expand the Logical Volume

To increase the LV to 300 MiB:

Unmount the filesystem: umount /kdyzm_lv Resize the LV: lvextend -L 300M /dev/storage/kdyzm_lv Check filesystem integrity: e2fsck -f /dev/storage/kdyzm_lv Resize the filesystem to use the new space: resize2fs /dev/storage/kdyzm_lv Remount the filesystem:

mount /dev/storage/kdyzm_lv /kdyzm_lv

5. Shrink the Logical Volume

Reducing an LV is riskier; the filesystem must be checked first.

Unmount the LV: umount /kdyzm_lv Run a forced filesystem check: e2fsck -f /dev/storage/kdyzm_lv Resize the filesystem to the target size (e.g., 100 MiB): resize2fs /dev/storage/kdyzm_lv 100M Reduce the LV itself: lvreduce -L 100M /dev/storage/kdyzm_lv Remount the LV:

mount /dev/storage/kdyzm_lv /kdyzm_lv

6. Delete the Logical Volume, Volume Group, and Physical Volumes

Removal must follow the reverse order:

Unmount and delete the LV:

umount /kdyzm_lv
lvremove /dev/storage/kdyzm_lv

Delete the VG: vgremove storage Erase the PV metadata:

pvremove /dev/sdb /dev/sdc

Key Takeaways

LVM abstracts physical storage, allowing administrators to allocate, resize, and reclaim space without repartitioning disks. All operations are performed via simple command‑line tools, but careful ordering—especially when shrinking—is essential to avoid data loss.

StorageSystem AdministrationLVMLogical Volume Manager
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.