Course contentsShow
← Linux
Lesson 631 of 1,8197. Storage Management and Logical VolumesFree lesson

Ext4 internal structure and allocation

Examine the inode-based architecture and extent-based storage allocation in the Ext4 filesystem.

In this lesson, you will learn how Ext4 efficiently tracks file locations using its inode-based architecture and extent-based storage allocation.

To understand how Linux knows where a file lives on a disk, we must look at the inode. Think of an inode as the "ID card" for a file. It stores metadata—permissions, owner, timestamps, and size—but crucially, it does not store the file name or the actual data. Instead, it contains pointers that tell the system where the data blocks are located on the physical storage.

The Shift to Extents

Older filesystems used "indirect blocks," which were inefficient for large files because they required a massive list of individual block pointers. Ext4 replaced this with Extents.

An extent is a way of describing a large, contiguous range of physical blocks using a single descriptor. Instead of listing every single block ID for a 100MB file, an extent simply says: "The data for this file starts at block 1000 and continues for the next 25,600 blocks."

This dramatically reduces metadata overhead and improves performance because the filesystem can read large chunks of data in a single operation.

Visualizing the Structure

You can see this structure in action by using debugfs on an unmounted filesystem (or a read-only partition). If you inspect a file’s inode metadata, you will see the extent tree:

# debugfs -R 'stat /home/user/largefile.iso' /dev/sda1
Inode: 12345   Type: regular   Mode: 0644   Flags: 0x80000
Extent: [0:32768:1024]

In this output:

  • 0: The logical starting block of the file.
  • 32768: The physical starting block on the disk.
  • 1024: The number of contiguous blocks (the extent length).

If a file is fragmented and cannot fit into a single contiguous area, Ext4 simply creates a tree of multiple extents to point to the different "islands" of data. This balance of keeping data contiguous whenever possible while allowing for flexibility makes Ext4 both fast and resilient.

Key Takeaway: Ext4 uses inodes to store metadata and extent-based allocation to map large, contiguous chunks of data, which significantly boosts performance by reducing the need to track individual blocks.