Master LVM: From Core Concepts to Practical Commands and Setup
This guide explains the fundamentals of Logical Volume Manager (LVM), its key components, major advantages, reasons to adopt it, essential management commands with examples, and step‑by‑step procedures for creating physical volumes, volume groups, logical volumes, and mounting them for real‑world Linux storage solutions.
LVM Overview
Logical Volume Manager (LVM) is a disk management mechanism that allows dynamic resizing of storage without affecting existing data, enhancing flexibility for system administrators.
Basic Concepts
PV (Physical Volume) : The basic storage unit in LVM, which can be an entire disk or a partition, used as the foundation for creating volume groups.
VG (Volume Group) : A storage pool composed of one or more physical volumes, providing a unified resource for logical volumes. Volume groups can be expanded or reduced by adding or removing physical volumes.
LV (Logical Volume) : Storage allocated from a volume group, similar to a traditional partition but with greater flexibility. Logical volumes can be resized on‑the‑fly and used to host file systems.
PE (Physical Extent) : The smallest allocation unit within a volume group. Each physical volume is divided into equal‑sized PEs, and logical volumes are built from these PEs.
/boot Partition : Stores boot files and cannot be managed by LVM; it must remain a standard physical partition.
LVM Main Advantages
Dynamic storage adjustment : Resize logical volumes while the system is running.
Simplified disk management : Aggregate multiple disks into a single pool for easier addition or removal.
Snapshot capability : Create point‑in‑time snapshots for backup and recovery.
Improved storage utilization : Reduce fragmentation and unused space.
Reasons to Use LVM
Flexibility
Reliability : Supports hot‑backup and dynamic data migration, allowing recovery without downtime.
Manageability : Centralized monitoring and control of multiple disks and volumes.
Performance : Efficient block‑level I/O and the ability to leverage parallelism across disks.
High availability : Can build RAID‑like redundancy within volume groups.
LVM Management Commands
Main Commands
Scan: pvscan vgscan lvscan
Create: pvcreate vgcreate lvcreate
Display: pvdisplay vgdisplay lvdisplay
Remove: pvremove vgremove lvremove
Extend: - vgextend lvextend
Reduce: - vgreduce lvreduceCommon Commands with Examples
1. Create Physical Volume (pvcreate) pvcreate creates a physical volume on a specified device. pvcreate /dev/sda1 /dev/sdb1 2. Create Volume Group (vgcreate) vgcreate my_volume_group /dev/sda1 /dev/sdb1 3. Create Logical Volume (lvcreate)
lvcreate -L 10G -n my_logical_volume my_volume_group4. Extend Logical Volume (lvextend)
lvextend -L +5G /dev/my_volume_group/my_logical_volumeLVM Application
Recommended Steps
Install the lvm2 package.
Convert physical disks to physical volumes (e.g., /dev/sdb1 and /dev/sdc1).
Create a volume group (e.g., mail_store) using the physical volumes.
Create a logical volume within the volume group (e.g., /dev/mail_store/mbox).
Format the logical volume with a filesystem (e.g., XFS) and mount it (e.g., /mailbox).
Ops Community
A leading IT operations community where professionals share and grow together.
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.
