How Linux LVM Manages Volume Groups Across Disks
The Logical Volume Manager (LVM) in Linux provides a flexible method for pooling storage across multiple physical drives into a single administrative unit known as a Volume Group (VG). By inserting an abstraction layer between physical hardware and the file system, LVM allows administrators to create dynamic Logical Volumes (LVs) that seamlessly span multiple physical disks without being constrained by individual partition boundaries. This guide explains the underlying mechanisms—including physical extents, device-mapper kernel drivers, and data allocation strategies—that Linux uses to manage these multi-disk configurations.
The Core Architecture: PVs, VGs, and LVs
To manage storage across multiple disks, LVM relies on a three-tier hierarchical architecture:
- Physical Volumes (PVs): Individual disks, SSDs, or
standard disk partitions are initialized as PVs using the
pvcreatecommand. This process writes an LVM label and metadata area to the beginning of the drive. - Volume Groups (VGs): Multiple PVs are combined into
a single storage pool using
vgcreateorvgextend. The VG treats all underlying physical space as a single, contiguous pool of available storage. - Logical Volumes (LVs): Block devices carved out of
the VG using
lvcreate. These act as virtual partitions where file systems (such as ext4 or XFS) are created and mounted.
Physical Extents: The Building Blocks of Allocation
The primary mechanism that enables an LVM Volume Group to span physical drives is the Physical Extent (PE).
When a Volume Group is created, all assigned storage is divided into uniform, fixed-size chunks called Physical Extents, typically 4MB by default. Similarly, Logical Volumes are composed of Logical Extents (LEs) of the exact same size.
LVM manages multi-disk spanning by maintaining a mapping table that links each Logical Extent in a Logical Volume to a specific Physical Extent on any available Physical Volume. Because of this 1:1 mapping between LEs and PEs, a Logical Volume can draw its required extents from completely different physical disks while presenting a single, continuous block device to the operating system.
Allocation Policies Across Multiple Disks
When a Logical Volume spans multiple disks within a Volume Group, Linux manages data placement according to configured allocation policies:
- Linear Allocation (Default): Extents are allocated sequentially. LVM fills the available Physical Extents on the first disk before automatically continuing onto the next disk. This provides a simple concatenation of storage space.
- Striped Allocation: Similar to RAID 0, LVM can alternate chunks of data across multiple physical drives. This round-robin distribution increases read/write performance by leveraging the I/O bandwidth of multiple disks simultaneously.
- Mirrored and RAID Modes: LVM can allocate extents redundantly across distinct physical disks within the same Volume Group. This ensures that if one disk fails, identical copies of the extents are preserved on another drive.
The Role of the Linux Device Mapper
At the operating system level, LVM relies on the Linux kernel's
Device Mapper framework (dm-mod).
The Device Mapper provides the low-level block-device translation layer. When an application or file system requests an I/O operation at a specific logical block address, the Device Mapper intercepts the request. It references the extent mapping table provided by the LVM metadata and translates the logical block address into the exact physical device identifier and physical sector number on the appropriate underlying drive.
Metadata Management and Dynamic Expansion
Linux stores identical copies of the Volume Group's configuration metadata in the header area of every Physical Volume assigned to that group. This metadata describes the entire topology, including the list of PVs, the active LVs, and the complete PE-to-LE mapping tables.
Because metadata is distributed and synchronized across all member disks:
- Dynamic Expansion: Administrators can attach new physical disks to an active Volume Group at runtime. Once the new drive's PEs are registered, existing Logical Volumes can be extended across the new disk with zero downtime.
- Data Migration: Using the
pvmoveutility, the Linux kernel can copy allocated extents from one physical disk to another within the same Volume Group while the filesystem remains online, enabling drive replacement and rebalancing without service interruption.