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
Offset
Size
Type
Field
Notes
0x4
16
bytes
–
0x20
8
u64 LE
Area Size
0x28
8
u64 LE
Location Offset
0x30
8
u64 LE
Location Size
0x3C
4
u32 LE
Location Flags
Read Locations
Offset
Size
Type
Field
Notes
position
8
u64 LE
Offset
position + 8
8
u64 LE
Size
Other fields read
Read in
Offset
Size
Type
Field
Notes
Is Label
0x18
8
bytes
–
Constants
Lvm Physical Volume Label
Name
Value
Type
Notes
LabelScanSectors
4
int
Lvm Metadata Reader
Name
Value
Type
Notes
HeaderSize
512
int
RawLocationIgnored
0x1
uint
AreaMagic
Encoding.ASCII.GetBytes(” LVM2 x[5A%r0N*>”)
byte[]
Older copies still in the circular buffer.
Name
Value
Type
Notes
marker
” {\nid = \””
string
Lvm Module
Name
Value
Type
Notes
RegistryKey
“lvm2:registry”
string
Implementation limits
Class
Name
Value
Notes
Lvm Config Parser
MaxDepth
32
Lvm Config Parser
MaxListItems
1_000_000
Lvm Physical Volume Label
MaxAreas
16
Lvm Metadata Reader
MaxAreaBytes
64L * 1024 * 1024
Lvm Module
MaxLvNesting
8
Signatures and magic strings referenced
Text
Where checked
LABELONE
Is Label
LVM2 001
Is Label
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.