Master Linux Storage: Complete Guide to LVM Installation, Management, and Scaling
This article explains why Linux administrators need flexible storage, introduces Logical Volume Manager (LVM), details its core concepts, walks through installation, creation of physical volumes, volume groups, logical volumes, formatting, mounting, and provides step‑by‑step procedures for expanding and shrinking LVM volumes on both ext4 and XFS filesystems.
Introduction
When installing Linux, administrators often struggle to accurately size partitions and anticipate future growth, which can lead to costly re‑partitioning and data migration. Dynamic tools exist but may still require downtime, especially for critical servers or when spanning multiple disks. Linux’s Logical Volume Manager (LVM) offers a zero‑downtime solution for flexible, cross‑disk volume management.
What Is LVM?
LVM (Logical Volume Manager) aggregates one or more disk partitions into a single logical pool, allowing easy addition of new partitions and dynamic space management, overcoming the rigidity of traditional partitioning.
LVM Basic Terminology
LVM adds a logical layer between disk partitions and file systems, providing abstract volumes for file system creation. Key terms include:
Physical Volume (PV) : The lowest layer, can be a disk partition or whole disk.
Volume Group (VG) : Built on PVs; a VG can contain one or many PVs and can be expanded by adding PVs.
Logical Volume (LV) : Created within a VG; space can be dynamically expanded or reduced.
Physical Extent (PE) : Smallest allocatable unit on a PV, size fixed at PV creation.
Logical Extent (LE) : Smallest allocatable unit on an LV, matching the PE size of its VG.
VG Descriptor Area (VGDA) : Metadata stored on each PV describing its VG, LVs, and PE allocations.
Installing LVM
Check if the lvm tools are installed (rpm output). If not, install the LVM package from the repository or media. Ensure kernel support for LVM; on RedHat kernels this is enabled by default, otherwise enable "Multiple devices driver support (RAID and LVM)" and "Logical volume manager (LVM) Support" in the kernel configuration.
Multiple devices driver support (RAID and LVM)
<*> Logical volume manager (LVM) SupportAfter recompiling the kernel, LVM will be available. Activation scripts are included in RedHat 7+; the /etc/rc.d/rc.sysinit file contains:
# LVM initialization
if [ -e /proc/lvm -a -x /sbin/vgchange -a -f /etc/lvmtab ]; then
echo "Setting up Logical Volume Management:" && /sbin/vgscan && /sbin/vgchange -a y
fiOperation Workflow
Create PV → Create VG → Create LV → Format → Mount
1. Disk Partition
Set the partition type to LVM (code 8e). If the device node (e.g., /dev/sdbn) does not appear, run partprobe before proceeding.
2. Create Physical Volume
Run pvcreate /dev/sdbn. Verify with pvdisplay or pvs.
3. Create Volume Group
Run vgcreate vg1 /dev/sdbn. Verify with vgdisplay or vgs.
4. Create Logical Volume
Syntax: lvcreate [options] [VG] Options:
-L size (e.g., 10G)
-n name
Verify with lvdisplay or lvs.
5. Format & Mount
Format the LV (e.g., mkfs.ext4 /dev/vg1/lv1) and mount it, adding an entry to /etc/fstab for persistence.
Expanding a Volume
Procedure: lvresize → e2fsck -f → resize2fs. Example commands are shown, and the volume must be unmounted before resizing.
lvresize adjusts LV size; use with caution as data loss is possible.
After resizing, run e2fsck to check the filesystem and resize2fs to apply the new size.
Shrinking (ext4 only)
Flow: unmount → e2fsck -f → resize2fs → lvresize. XFS does not support shrinking.
Expanding XFS Volumes
After formatting the LV as XFS, expand with lvresize followed by xfs_growfs (must be run while the filesystem is mounted).
Extending a Volume Group
Example: add /dev/sdb3 to vg1 using vgextend vg1 /dev/sdb3.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
