74 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3Checksums4---------5 6Starting in early 2012, metadata checksums were added to all major ext47and jbd2 data structures. The associated feature flag is metadata_csum.8The desired checksum algorithm is indicated in the superblock, though as9of October 2012 the only supported algorithm is crc32c. Some data10structures did not have space to fit a full 32-bit checksum, so only the11lower 16 bits are stored. Enabling the 64bit feature increases the data12structure size so that full 32-bit checksums can be stored for many data13structures. However, existing 32-bit filesystems cannot be extended to14enable 64bit mode, at least not without the experimental resize2fs15patches to do so.16 17Existing filesystems can have checksumming added by running18``tune2fs -O metadata_csum`` against the underlying device. If tune2fs19encounters directory blocks that lack sufficient empty space to add a20checksum, it will request that you run ``e2fsck -D`` to have the21directories rebuilt with checksums. This has the added benefit of22removing slack space from the directory files and rebalancing the htree23indexes. If you _ignore_ this step, your directories will not be24protected by a checksum!25 26The following table describes the data elements that go into each type27of checksum. The checksum function is whatever the superblock describes28(crc32c as of October 2013) unless noted otherwise.29 30.. list-table::31 :widths: 20 8 5032 :header-rows: 133 34 * - Metadata35 - Length36 - Ingredients37 * - Superblock38 - __le3239 - The entire superblock up to the checksum field. The UUID lives inside40 the superblock.41 * - MMP42 - __le3243 - UUID + the entire MMP block up to the checksum field.44 * - Extended Attributes45 - __le3246 - UUID + the entire extended attribute block. The checksum field is set to47 zero.48 * - Directory Entries49 - __le3250 - UUID + inode number + inode generation + the directory block up to the51 fake entry enclosing the checksum field.52 * - HTREE Nodes53 - __le3254 - UUID + inode number + inode generation + all valid extents + HTREE tail.55 The checksum field is set to zero.56 * - Extents57 - __le3258 - UUID + inode number + inode generation + the entire extent block up to59 the checksum field.60 * - Bitmaps61 - __le32 or __le1662 - UUID + the entire bitmap. Checksums are stored in the group descriptor,63 and truncated if the group descriptor size is 32 bytes (i.e. ^64bit)64 * - Inodes65 - __le3266 - UUID + inode number + inode generation + the entire inode. The checksum67 field is set to zero. Each inode has its own checksum.68 * - Group Descriptors69 - __le1670 - If metadata_csum, then UUID + group number + the entire descriptor;71 else if gdt_csum, then crc16(UUID + group number + the entire72 descriptor). In all cases, only the lower 16 bits are stored.73 74