Linux MD RAID

Linux MD is the kernel’s software RAID (levels 0, 1, 4, 5, 6 and 10), managed by mdadm and identified by a superblock on each member. It is common in Linux servers and many NAS devices, including Synology, and it is actively maintained.

Overview

MD members carry a superblock identifying the array UUID, RAID level, chunk size, layout, member number and event counter. Version 0.90 stores it near the end of the device, 1.0 at the end, 1.1 at the start and 1.2 4 KiB from the start. Supported levels include linear, RAID0, RAID1, RAID4, RAID5, RAID6 and RAID10. When metadata is damaged the implementation can solve disk order and layout heuristically.

History

  • Developed by Ingo Molnar and later Neil Brown for Linux 2.x; superblock version 1 introduced around 2006.

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 Version090

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x44u32 LE–
0x84u32 LE–
at4u32 LE0
10 * 44u32 LERaid Disks
11 * 44u32 LEName
32 * 44u32 LEUpdated
38 * 44u32 LE–
39 * 44u32 LEEvents
40 * 44u32 LEEvents
6 * 44u32 LECreated
64 * 44u32 LELayout
65 * 44u32 LEChunk Bytes
7 * 44u32 LELevel
8 * 44u32 LEUsed SectorsKB
w * 44u32 LEW
thisDisk + 124u32 LERaid Disk
thisDisk + 164u32 LEState

Read Version1

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x44u32 LE–
0x84u32 LEFeatures
0x408u64 LECreated
0x484u32 LELevel
0x4C4u32 LELayout
0x508u64 LEUsed Sectors
0x584u32 LEChunk Bytes
0x5C4u32 LERaid Disks
0x808u64 LEData Offset
0x888u64 LEData Size
0x908u64 LESuper Offset
0xA04u32 LEDev Number
0xC08u64 LEUpdated
0xC88u64 LEEvents
0xD84u32 LE–
0xDC4u32 LEAx Dev
at4u32 LE0
at2u16 LE–
256 + (int)devNumber * 22u16 LEValue

Time40

OffsetSizeTypeFieldNotes
at2u16 LE–
at4u32 LE–
at8u64 LE–

Constants

Md Raid Module

NameValueTypeNotes
MagicV1[0xFC, 0x4E, 0x2B, 0xA9, 0x01, 0x00, 0x00, 0x00]byte[]

Md Superblock

NameValueTypeNotes
Magic0xA92B4EFCuint
BlockSize4096int
Sector512int

Raid Order Solver

NameValueTypeNotes
Mounted4int

Implementation limits

ClassNameValueNotes
Raid Order SolverMaxUnknown7
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.