How Ext4 File System Manages Data in Linux

The fourth extended filesystem (ext4) is the default and most widely adopted storage system in modern Linux distributions, engineered to organize, store, and retrieve files with high reliability and speed. This article examines the core mechanics of ext4 data management, detailing how it uses block groups, inodes, extents, advanced allocation techniques, and journaling to maintain file system integrity and optimize read/write performance.

Block Groups

To minimize fragmentation and reduce disk seek times, ext4 divides a storage partition into segments known as block groups. Rather than scattering file data and metadata across the entire drive, ext4 groups related information together. Each block group contains:

Inodes and Metadata Management

Every file and directory in ext4 is represented by an inode (index node). Inodes store metadata, including file size, permissions, owner, timestamps, and access control lists (ACLs). Crucially, inodes do not store the filename or the file content itself. Filenames are maintained in directory data blocks, which map human-readable names to their corresponding inode numbers. In ext4, default inodes are 256 bytes, providing ample room for extended attributes and timestamps accurate down to the nanosecond.

Extents

Older Linux filesystems like ext3 used indirect block mapping, requiring individual pointers for every data block. Ext4 replaces this mechanism with extents. An extent represents a range of contiguous physical storage blocks mapped via a single descriptor (up to 128 MB per extent using standard 4 KB blocks). A single inode can store up to four extents directly. For larger files requiring more than four extents, ext4 organizes them into an efficient H-tree structure. This approach drastically reduces metadata overhead and accelerates large file read and write operations.

Allocation Techniques

Ext4 improves write performance and prevents fragmentation using two key allocation strategies:

Journaling and Data Integrity

To protect against corruption during unexpected shutdowns or power failures, ext4 relies on the Journaling Block Device (JBD2) layer. Before changes are committed to the main storage area, they are recorded in a dedicated journal space. Ext4 supports three journaling modes: