LVM2 (Logical Volume Manager)

LVM2 is the Linux logical volume manager, pooling physical volumes into volume groups from which logical volumes are carved. It is the default on many Linux server installations and on RHEL and Fedora systems, and it is actively maintained.

Overview

LVM2 physical volumes carry a label (LABELONE) in one of the first four sectors, followed by a PV header and data/metadata area descriptors. The metadata area stores a ring buffer of text-format configuration describing volume groups, physical volumes and logical volumes. Logical volumes are built from segments (linear, striped, mirror, thin and others) mapped to physical extents.

History

  • LVM2 was written by Heinz Mauelshagen and Alasdair Kergon and replaced the original LVM in Linux 2.6 (2003-2004).

Structures

Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

Read All

OffsetSizeTypeFieldNotes
0x416bytes–
0x208u64 LEArea Size
0x288u64 LELocation Offset
0x308u64 LELocation Size
0x3C4u32 LELocation Flags

Read Locations

OffsetSizeTypeFieldNotes
position8u64 LEOffset
position + 88u64 LESize

Other fields read

Read inOffsetSizeTypeFieldNotes
Is Label0x188bytes–

Constants

Lvm Physical Volume Label

NameValueTypeNotes
LabelScanSectors4int

Lvm Metadata Reader

NameValueTypeNotes
HeaderSize512int
RawLocationIgnored0x1uint
AreaMagicEncoding.ASCII.GetBytes(” LVM2 x[5A%r0N*>”)byte[]

Older copies still in the circular buffer.

NameValueTypeNotes
marker” {\nid = \””string

Lvm Module

NameValueTypeNotes
RegistryKey“lvm2:registry”string

Implementation limits

ClassNameValueNotes
Lvm Config ParserMaxDepth32
Lvm Config ParserMaxListItems1_000_000
Lvm Physical Volume LabelMaxAreas16
Lvm Metadata ReaderMaxAreaBytes64L * 1024 * 1024
Lvm ModuleMaxLvNesting8

Signatures and magic strings referenced

TextWhere checked
LABELONEIs Label
LVM2 001Is Label
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.