1.About this Book¶
This document attempts to describe the on-disk format for ext4filesystems. The same general ideas should apply to ext2/3 filesystemsas well, though they do not support all the features that ext4 supports,and the fields will be shorter.
NOTE: This is a work in progress, based on notes that the author(djwong) made while picking apart a filesystem by hand. The datastructure definitions should be current as of Linux 4.18 ande2fsprogs-1.44. All comments and corrections are welcome, since there isundoubtedly plenty of lore that might not be reflected in freshlycreated demonstration filesystems.
1.1.License¶
This book is licensed under the terms of the GNU Public License, v2.
1.2.Terminology¶
ext4 divides a storage device into an array of logical blocks both toreduce bookkeeping overhead and to increase throughput by forcing largertransfer sizes. Generally, the block size will be 4KiB (the same size aspages on x86 and the block layer’s default block size), though theactual size is calculated as 2 ^ (10 +sb.s_log_block_size) bytes.Throughout this document, disk locations are given in terms of theselogical blocks, not raw LBAs, and not 1024-byte blocks. For the sake ofconvenience, the logical block size will be referred to as$block_size throughout the rest of the document.
When referenced inpreformattedtext blocks,sb refers to fieldsin the super block, andinode refers to fields in an inode tableentry.
1.3.Other References¶
Also seehttps://www.nongnu.org/ext2-doc/ for quite a collection ofinformation about ext2/3. Here’s another old reference:http://wiki.osdev.org/Ext2