Operations 19 min read

Mastering LVM on Linux: Step‑by‑Step Guide to Create, Extend, and Manage Logical Volumes

This article provides a comprehensive, hands‑on tutorial for Linux Logical Volume Manager (LVM), covering installation environment setup, creating physical volumes, volume groups, logical volumes, extending them, resizing file systems, and adding new disks, complete with command‑line examples and explanations.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering LVM on Linux: Step‑by‑Step Guide to Create, Extend, and Manage Logical Volumes

1. Introduction to LVM

LVM (Logical Volume Manager) adds a flexible abstraction layer between physical disks and file systems, allowing dynamic resizing of partitions without data loss. It groups multiple disks into volume groups (VG) and creates logical volumes (LV) that can be resized on demand.

2. Test Environment

Platform: VMware Workstation 17 Pro Guest OS: Rocky Linux 8.9

3. Practical Examples

3.1 Create Physical Volume (PV)

parted /dev/sdb print          # view disk info
pvcreate /dev/sdb               # create PV

Verify PV status:

pvscan
pvs
pvdisplay /dev/sdb

3.2 Create Volume Group (VG)

vgcreate vgtest /dev/sdb        # create VG named vgtest

Check VG status:

vgscan
vgs
vgdisplay vgtest

3.3 Create Logical Volume (LV)

lvcreate -l 100%FREE vgtest -n lvtest   # allocate all VG space to LV

View LV information:

lvscan
lvs
lvdisplay vgtest/lvtest

3.4 Extend Logical Volume

Increase LV size by 200 MiB: lvextend -L +200M vgtest2/lvtest2 Or extend by a number of extents: lvextend -l +25 vgtest2/lvtest2 Allocate all free space:

lvextend -l +100%FREE vgtest2/lvtest2

3.5 Mount and Persistently Mount LV

mkfs.xfs /dev/vgtest2/lvtest2          # create XFS filesystem
mkdir /data
mount /dev/vgtest2/lvtest2 /data
blkid /dev/vgtest2/lvtest2               # get UUID
# Add to /etc/fstab for permanent mount
UUID="544fae3b-7d08-4090-a6a7-aa5bcc4d9be0" /data xfs defaults 0 0

3.6 Expand VG with New Disks

Rescan SCSI hosts to detect new disks, then create a new PV and extend the VG:

echo "- - -" > /sys/class/scsi_host/host0/scan
# repeat for host1, host2
pvcreate /dev/sdf
vgextend vgtest2 /dev/sdf

After extending the VG, enlarge the LV and the filesystem:

lvextend -l +100%FREE vgtest2/lvtest2
xfs_growfs /dev/vgtest2/lvtest2

3.7 Resize LV and Filesystem in One Step

pvcreate /dev/sdg
vgextend vgtest2 /dev/sdg
lvextend -L +5G -r vgtest2/lvtest2   # extend LV by 5 GiB and resize XFS automatically

The article demonstrates the full lifecycle of LVM management: creating PVs, VGs, LVs, extending them, mounting, and handling storage growth without rebooting.

LinuxSystem AdministrationLVMStorage ManagementLogical Volume Manager
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.