ext2, ext3 and ext4 (Extended File System)

The ext family is the standard Linux file system: ext2 (1993), ext3 (journaling, 2001) and ext4 (extents and 64-bit sizes, 2008). ext4 is the default on many distributions and is also found on Android devices, NAS boxes, Chromebooks and virtual machine disks, and the format is actively maintained.

Overview

The ext family divides the volume into block groups, each with a copy of or pointer to group descriptors, bitmaps, an inode table and data blocks. The superblock sits 1024 bytes from the start. ext2 uses indirect block maps; ext3 adds a journal; ext4 adds extents, 64-bit sizes, flex block groups, metadata checksums and other feature flags (compatible, incompatible and read-only compatible sets).

History

  • ext was written by Rémy Card in 1992; ext2 followed in 1993.
  • ext3 added journaling and was merged into Linux 2.4.15 (2001).
  • ext4 was marked stable in Linux 2.6.28 (2008).

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.

Has Block Map

OffsetSizeTypeFieldNotes
0x02u16 LE–
0x22u16 LE–
i * 44u32 LE–

Has Non Zero Extent

OffsetSizeTypeFieldNotes
0x22u16 LEEntries
0x62u16 LELeaf
entry + 44u32 LE–
entry + 42u16 LE–
entry + 62u16 LE–
entry + 84u32 LE–
entry + 82u16 LE–

Inode Attribute

OffsetSizeTypeFieldNotes
0x802u16 LEStart
position4u32 LE–
start4u32 LE–
position + 11u8Index
position + 22u16 LEValue Offset
position + 44u32 LEValue Inode
position + 84u32 LEValue Size

Is Directory Block

OffsetSizeTypeFieldNotes
position4u32 LE–
position + 42u16 LERecord Length
position + 62u16 LEName Length
position + 61u8Name Length

Map Blocks

OffsetSizeTypeFieldNotes
44 + level * 44u32 LE–
i * 44u32 LE–

Read Metadata Block

OffsetSizeTypeFieldNotes
0x02u16 LE–
0x22u16 LE–

Recovered Inodes

OffsetSizeTypeFieldNotes
0x02u16 LE–
0x144u32 LENow Deleted
0x144u32 LE–
0x1A2u16 LE–
0x644u32 LESame Generation

Recovered Inodes

OffsetSizeTypeFieldNotes
0x02u16 LE–
0x144u32 LE–
0x1A2u16 LE–
0x644u32 LE–

Scan Deleted Inodes

OffsetSizeTypeFieldNotes
0x02u16 LE–
0x144u32 LE–

Walk Extent Node

OffsetSizeTypeFieldNotes
0x04u32 LELogical
0x42u16 LELength
0x44u32 LEChild
0x62u16 LEPhysical
0x84u32 LEPhysical
0x82u16 LEChild

Walk Extent Node

OffsetSizeTypeFieldNotes
0x02u16 LE–
0x22u16 LEEntries
0x62u16 LEDepth

Parse Dirents

OffsetSizeTypeFieldNotes
position4u32 LEInode
position + 42u16 LERecord Length
position + 62u16 LEName Length
position + 61u8Name Length
position + 71u8File Type

Scan Slack

OffsetSizeTypeFieldNotes
position4u32 LEInode
position + 42u16 LERecord Length
position + 62u16 LEName Length
position + 61u8Name Length
position + 71u8File Type

Index

OffsetSizeTypeFieldNotes
0x04u32 BE–
0x44u32 BE–
0x84u32 BESequence

Index

OffsetSizeTypeFieldNotes
0x04u32 BETarget
0x44u32 BEFlags
0x62u16 BEFlags
0x84u32 BE–

Load

OffsetSizeTypeFieldNotes
0x04u32 BE–
0x44u32 BEType
0xC4u32 BEJournal Block Size
0x104u32 BEAx Length
0x144u32 BEFirst
0x284u32 BE–

Parse

OffsetSizeTypeFieldNotes
0x02u16 LEOde
0x22u16 LEUid
0x44u32 LESize
0x144u32 LEDeletion Time
0x182u16 LEGid
0x1A2u16 LELinks
0x1C4u32 LEBlocks
0x204u32 LEFlags
0x2860bytesBlock Field
0x644u32 LEGeneration
0x684u32 LEFile Acl
0x6C4u32 LESize High
0x742u16 LEBlocks
0x762u16 LEFile Acl
0x782u16 LEUid
0x7A2u16 LEGid
0x802u16 LEExtra Size

Time

OffsetSizeTypeFieldNotes
extraOffset4u32 LEExtra
offset4u32 LESeconds

Try Parse

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x04u32 LEInodes Count
0x44u32 LEBlocks
0xC4u32 LEFree Blocks
0x104u32 LEFree Inodes
0x144u32 LEFirst Data Block
0x184u32 LELog Block Size
0x204u32 LEBlocks Per Group
0x284u32 LEInodes Per Group
0x2C4u32 LELast Mount Time
0x304u32 LELast Write Time
0x382u16 LE–
0x3A2u16 LEState
0x4C4u32 LERevision
0x544u32 LE–
0x582u16 LE–
0x5A2u16 LE–
0x5C4u32 LE–
0x604u32 LE–
0x644u32 LE–
0xE04u32 LE–
0xFE2u16 LEDescriptor Size
0x1044u32 LEFirst Meta Group
0x1504u32 LEBlocks
0x1584u32 LEFree Blocks

Parse

OffsetSizeTypeFieldNotes
0x04u32 LE–
0x84u32 LE–
0x122u16 LE–
0x1C2u16 LE–
0x204u32 LE–
0x284u32 LE–
0x322u16 LE–

Other fields read

Read inOffsetSizeTypeFieldNotes
Read Symlink0x02u16 LEExtent Header
Walk Indirecti * 44u32 LEEntry
Index0x04u32 BE–
Has Root Directory0x02u16 LE–

Constants

Ext File System

NameValueTypeNotes
ExtentMagic0xF30Aushort
RootInode2uint
StrictUtf8new(false, true)UTF8Encoding

Ext Journal

NameValueTypeNotes
Magic0xC03B3998uint
TypeDescriptor1uint
TypeSuperblockV13uint
TypeSuperblockV24uint
Incompat64Bit0x2uint
IncompatCsumV20x8uint
IncompatCsumV30x10uint
TagEscape0x1uint
TagSameUuid0x2uint
TagLast0x8uint

s_feature_compat

NameValueTypeNotes
CompatHasJournal0x4uint

s_feature_incompat

NameValueTypeNotes
IncompatFileType0x2uint
IncompatRecover0x4uint
IncompatMetaBg0x10uint
IncompatExtents0x40uint
Incompat64Bit0x80uint
IncompatFlexBg0x200uint
IncompatLargeDir0x4000uint
IncompatInlineData0x8000uint
IncompatEncrypt0x10000uint

s_feature_ro_compat

NameValueTypeNotes
RoCompatSparseSuper0x1uint
RoCompatLargeFile0x2uint
RoCompatGdtCsum0x10uint
RoCompatHugeFile0x8uint
RoCompatExtraIsize0x40uint
RoCompatBigAlloc0x200uint
RoCompatMetadataCsum0x400uint

Ext Superblock

NameValueTypeNotes
Magic0xEF53ushort

Struct

NameValueTypeNotes
BlockUninit0x2ushort
InodeUninit0x1ushort

Ext Inode

NameValueTypeNotes
FlagImmutable0x10uint
FlagAppend0x20uint
FlagEncrypted0x800uint
FlagIndex0x1000uint
FlagHugeFile0x40000uint
FlagExtents0x80000uint
FlagInlineData0x10000000uint

Ext Module

NameValueTypeNotes
SuperblockOffset1024int
SuperblockSize1024int

Implementation limits

ClassNameValueNotes
Ext File SystemMaxExtentDepth5
Ext File SystemMaxMappings4_000_000
Ext File SystemMaxDirectoryBytes256L * 1024 * 1024
Ext File SystemMaxSymlinkLength4096
Ext File SystemMaxLostEntries200_000
Ext File SystemMaxOverwriteChecks256
Ext Allocation MapMaxCachedGroups256
Ext JournalMaxCopiesPerBlock64

Entry Kind

NameValue
Live(next)
Deleted(next)
Recovered(next)
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.