162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciAbout this Book 462306a36Sopenharmony_ci=============== 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciThis document attempts to describe the on-disk format for ext4 762306a36Sopenharmony_cifilesystems. The same general ideas should apply to ext2/3 filesystems 862306a36Sopenharmony_cias well, though they do not support all the features that ext4 supports, 962306a36Sopenharmony_ciand the fields will be shorter. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci**NOTE**: This is a work in progress, based on notes that the author 1262306a36Sopenharmony_ci(djwong) made while picking apart a filesystem by hand. The data 1362306a36Sopenharmony_cistructure definitions should be current as of Linux 4.18 and 1462306a36Sopenharmony_cie2fsprogs-1.44. All comments and corrections are welcome, since there is 1562306a36Sopenharmony_ciundoubtedly plenty of lore that might not be reflected in freshly 1662306a36Sopenharmony_cicreated demonstration filesystems. 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciLicense 1962306a36Sopenharmony_ci------- 2062306a36Sopenharmony_ciThis book is licensed under the terms of the GNU Public License, v2. 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciTerminology 2362306a36Sopenharmony_ci----------- 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciext4 divides a storage device into an array of logical blocks both to 2662306a36Sopenharmony_cireduce bookkeeping overhead and to increase throughput by forcing larger 2762306a36Sopenharmony_citransfer sizes. Generally, the block size will be 4KiB (the same size as 2862306a36Sopenharmony_cipages on x86 and the block layer's default block size), though the 2962306a36Sopenharmony_ciactual size is calculated as 2 ^ (10 + ``sb.s_log_block_size``) bytes. 3062306a36Sopenharmony_ciThroughout this document, disk locations are given in terms of these 3162306a36Sopenharmony_cilogical blocks, not raw LBAs, and not 1024-byte blocks. For the sake of 3262306a36Sopenharmony_ciconvenience, the logical block size will be referred to as 3362306a36Sopenharmony_ci``$block_size`` throughout the rest of the document. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ciWhen referenced in ``preformatted text`` blocks, ``sb`` refers to fields 3662306a36Sopenharmony_ciin the super block, and ``inode`` refers to fields in an inode table 3762306a36Sopenharmony_cientry. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciOther References 4062306a36Sopenharmony_ci---------------- 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciAlso see https://www.nongnu.org/ext2-doc/ for quite a collection of 4362306a36Sopenharmony_ciinformation about ext2/3. Here's another old reference: 4462306a36Sopenharmony_cihttp://wiki.osdev.org/Ext2 45