^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) About this Book
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) ===============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) This document attempts to describe the on-disk format for ext4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) filesystems. The same general ideas should apply to ext2/3 filesystems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) as well, though they do not support all the features that ext4 supports,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) and the fields will be shorter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) **NOTE**: This is a work in progress, based on notes that the author
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) (djwong) made while picking apart a filesystem by hand. The data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) structure definitions should be current as of Linux 4.18 and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) e2fsprogs-1.44. All comments and corrections are welcome, since there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) undoubtedly plenty of lore that might not be reflected in freshly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) created demonstration filesystems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) -------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) This book is licensed under the terms of the GNU Public License, v2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Terminology
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ext4 divides a storage device into an array of logical blocks both to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) reduce bookkeeping overhead and to increase throughput by forcing larger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) transfer sizes. Generally, the block size will be 4KiB (the same size as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) pages on x86 and the block layer's default block size), though the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) actual size is calculated as 2 ^ (10 + ``sb.s_log_block_size``) bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) Throughout this document, disk locations are given in terms of these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) logical blocks, not raw LBAs, and not 1024-byte blocks. For the sake of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) convenience, the logical block size will be referred to as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) ``$block_size`` throughout the rest of the document.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) When referenced in ``preformatted text`` blocks, ``sb`` refers to fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) in the super block, and ``inode`` refers to fields in an inode table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) Other References
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Also see https://www.nongnu.org/ext2-doc/ for quite a collection of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) information about ext2/3. Here's another old reference:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) http://wiki.osdev.org/Ext2