1 .. SPDX-License-Identifier: GPL-2.0
6 The superblock records various information about the enclosing
7 filesystem, such as block counts, inode counts, supported features,
8 maintenance information, and more.
10 If the sparse\_super feature flag is set, redundant copies of the
11 superblock and group descriptors are kept only in the groups whose group
12 number is either 0 or a power of 3, 5, or 7. If the flag is not set,
13 redundant copies are kept in all groups.
15 The superblock checksum is calculated against the superblock structure,
16 which includes the FS UUID.
18 The ext4 superblock is laid out as follows in
19 ``struct ext4_super_block``:
35 - s\_blocks\_count\_lo
39 - s\_r\_blocks\_count\_lo
40 - This number of blocks can only be allocated by the super-user.
43 - s\_free\_blocks\_count\_lo
47 - s\_free\_inodes\_count
51 - s\_first\_data\_block
52 - First data block. This must be at least 1 for 1k-block filesystems and
53 is typically 0 for all other block sizes.
57 - Block size is 2 ^ (10 + s\_log\_block\_size).
60 - s\_log\_cluster\_size
61 - Cluster size is (2 ^ s\_log\_cluster\_size) blocks if bigalloc is
62 enabled. Otherwise s\_log\_cluster\_size must equal s\_log\_block\_size.
65 - s\_blocks\_per\_group
69 - s\_clusters\_per\_group
70 - Clusters per group, if bigalloc is enabled. Otherwise
71 s\_clusters\_per\_group must equal s\_blocks\_per\_group.
74 - s\_inodes\_per\_group
79 - Mount time, in seconds since the epoch.
83 - Write time, in seconds since the epoch.
87 - Number of mounts since the last fsck.
91 - Number of mounts beyond which a fsck is needed.
95 - Magic signature, 0xEF53
99 - File system state. See super_state_ for more info.
103 - Behaviour when detecting errors. See super_errors_ for more info.
106 - s\_minor\_rev\_level
107 - Minor revision level.
111 - Time of last check, in seconds since the epoch.
115 - Maximum time between checks, in seconds.
119 - Creator OS. See the table super_creator_ for more info.
123 - Revision level. See the table super_revision_ for more info.
127 - Default uid for reserved blocks.
131 - Default gid for reserved blocks.
135 - These fields are for EXT4_DYNAMIC_REV superblocks only.
137 Note: the difference between the compatible feature set and the
138 incompatible feature set is that if there is a bit set in the
139 incompatible feature set that the kernel doesn't know about, it should
140 refuse to mount the filesystem.
142 e2fsck's requirements are more strict; if it doesn't know
143 about a feature in either the compatible or incompatible feature set, it
144 must abort and not try to meddle with things it doesn't understand...
148 - First non-reserved inode.
152 - Size of inode structure, in bytes.
155 - s\_block\_group\_nr
156 - Block group # of this superblock.
160 - Compatible feature set flags. Kernel can still read/write this fs even
161 if it doesn't understand a flag; fsck should not do that. See the
162 super_compat_ table for more info.
165 - s\_feature\_incompat
166 - Incompatible feature set. If the kernel or fsck doesn't understand one
167 of these bits, it should stop. See the super_incompat_ table for more
171 - s\_feature\_ro\_compat
172 - Readonly-compatible feature set. If the kernel doesn't understand one of
173 these bits, it can still mount read-only. See the super_rocompat_ table
178 - 128-bit UUID for volume.
181 - s\_volume\_name[16]
185 - s\_last\_mounted[64]
186 - Directory where filesystem was last mounted.
189 - s\_algorithm\_usage\_bitmap
190 - For compression (Not used in e2fsprogs/Linux)
194 - Performance hints. Directory preallocation should only happen if the
195 EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
198 - s\_prealloc\_blocks
199 - #. of blocks to try to preallocate for ... files? (Not used in
203 - s\_prealloc\_dir\_blocks
204 - #. of blocks to preallocate for directories. (Not used in
208 - s\_reserved\_gdt\_blocks
209 - Number of reserved GDT entries for future filesystem expansion.
213 - Journalling support is valid only if EXT4_FEATURE_COMPAT_HAS_JOURNAL is
217 - s\_journal\_uuid[16]
218 - UUID of journal superblock
222 - inode number of journal file.
226 - Device number of journal file, if the external journal feature flag is
231 - Start of list of orphaned inodes to delete.
238 - s\_def\_hash\_version
239 - Default hash algorithm to use for directory hashes. See super_def_hash_
243 - s\_jnl\_backup\_type
244 - If this value is 0 or EXT3\_JNL\_BACKUP\_BLOCKS (1), then the
245 ``s_jnl_blocks`` field contains a duplicate copy of the inode's
246 ``i_block[]`` array and ``i_size``.
250 - Size of group descriptors, in bytes, if the 64bit incompat feature flag
254 - s\_default\_mount\_opts
255 - Default mount options. See the super_mountopts_ table for more info.
259 - First metablock block group, if the meta\_bg feature is enabled.
263 - When the filesystem was created, in seconds since the epoch.
267 - Backup copy of the journal inode's ``i_block[]`` array in the first 15
268 elements and i\_size\_high and i\_size in the 16th and 17th elements,
273 - 64bit support is valid only if EXT4_FEATURE_COMPAT_64BIT is set.
276 - s\_blocks\_count\_hi
277 - High 32-bits of the block count.
280 - s\_r\_blocks\_count\_hi
281 - High 32-bits of the reserved block count.
284 - s\_free\_blocks\_count\_hi
285 - High 32-bits of the free block count.
288 - s\_min\_extra\_isize
289 - All inodes have at least # bytes.
292 - s\_want\_extra\_isize
293 - New inodes should reserve # bytes.
297 - Miscellaneous flags. See the super_flags_ table for more info.
301 - RAID stride. This is the number of logical blocks read from or written
302 to the disk before moving to the next disk. This affects the placement
303 of filesystem metadata, which will hopefully make RAID storage faster.
307 - #. seconds to wait in multi-mount prevention (MMP) checking. In theory,
308 MMP is a mechanism to record in the superblock which host and device
309 have mounted the filesystem, in order to prevent multiple mounts. This
310 feature does not seem to be implemented...
314 - Block # for multi-mount protection data.
317 - s\_raid\_stripe\_width
318 - RAID stripe width. This is the number of logical blocks read from or
319 written to the disk before coming back to the current disk. This is used
320 by the block allocator to try to reduce the number of read-modify-write
321 operations in a RAID5/6.
324 - s\_log\_groups\_per\_flex
325 - Size of a flexible block group is 2 ^ ``s_log_groups_per_flex``.
329 - Metadata checksum algorithm type. The only valid value is 1 (crc32c).
337 - Number of KiB written to this filesystem over its lifetime.
341 - inode number of active snapshot. (Not used in e2fsprogs/Linux.)
345 - Sequential ID of active snapshot. (Not used in e2fsprogs/Linux.)
348 - s\_snapshot\_r\_blocks\_count
349 - Number of blocks reserved for active snapshot's future use. (Not used in
354 - inode number of the head of the on-disk snapshot list. (Not used in
359 - Number of errors seen.
362 - s\_first\_error\_time
363 - First time an error happened, in seconds since the epoch.
366 - s\_first\_error\_ino
367 - inode involved in first error.
370 - s\_first\_error\_block
371 - Number of block involved of first error.
374 - s\_first\_error\_func[32]
375 - Name of function where the error happened.
378 - s\_first\_error\_line
379 - Line number where error happened.
382 - s\_last\_error\_time
383 - Time of most recent error, in seconds since the epoch.
386 - s\_last\_error\_ino
387 - inode involved in most recent error.
390 - s\_last\_error\_line
391 - Line number where most recent error happened.
394 - s\_last\_error\_block
395 - Number of block involved in most recent error.
398 - s\_last\_error\_func[32]
399 - Name of function where the most recent error happened.
403 - ASCIIZ string of mount options.
406 - s\_usr\_quota\_inum
407 - Inode number of user `quota <quota>`__ file.
410 - s\_grp\_quota\_inum
411 - Inode number of group `quota <quota>`__ file.
414 - s\_overhead\_blocks
415 - Overhead blocks/clusters in fs. (Huh? This field is always zero, which
416 means that the kernel calculates it dynamically.)
420 - Block groups containing superblock backups (if sparse\_super2)
423 - s\_encrypt\_algos[4]
424 - Encryption algorithms in use. There can be up to four algorithms in use
425 at any time; valid algorithm codes are given in the super_encrypt_ table
429 - s\_encrypt\_pw\_salt[16]
430 - Salt for the string2key algorithm for encryption.
434 - Inode number of lost+found
437 - s\_prj\_quota\_inum
438 - Inode that tracks project quotas.
442 - Checksum seed used for metadata\_csum calculations. This value is
443 crc32c(~0, $orig\_fs\_uuid).
447 - Upper 8 bits of the s_wtime field.
451 - Upper 8 bits of the s_mtime field.
455 - Upper 8 bits of the s_mkfs_time field.
459 - Upper 8 bits of the s_lastcheck_hi field.
462 - s\_first_error_time_hi
463 - Upper 8 bits of the s_first_error_time_hi field.
466 - s\_last_error_time_hi
467 - Upper 8 bits of the s_last_error_time_hi field.
475 - Padding to the end of the block.
479 - Superblock checksum.
483 The superblock state is some combination of the following:
496 - Orphans being recovered
500 The superblock error policy is one of the following:
517 The filesystem creator is one of the following:
538 The superblock revision is one of the following:
549 - v2 format w/ dynamic inode sizes
551 Note that ``EXT4_DYNAMIC_REV`` refers to a revision 1 or newer filesystem.
555 The superblock compatible features field is a combination of any of the
565 - Directory preallocation (COMPAT\_DIR\_PREALLOC).
567 - “imagic inodes”. Not clear from the code what this does
568 (COMPAT\_IMAGIC\_INODES).
570 - Has a journal (COMPAT\_HAS\_JOURNAL).
572 - Supports extended attributes (COMPAT\_EXT\_ATTR).
574 - Has reserved GDT blocks for filesystem expansion
575 (COMPAT\_RESIZE\_INODE). Requires RO\_COMPAT\_SPARSE\_SUPER.
577 - Has directory indices (COMPAT\_DIR\_INDEX).
579 - “Lazy BG”. Not in Linux kernel, seems to have been for uninitialized
580 block groups? (COMPAT\_LAZY\_BG)
582 - “Exclude inode”. Not used. (COMPAT\_EXCLUDE\_INODE).
584 - “Exclude bitmap”. Seems to be used to indicate the presence of
585 snapshot-related exclude bitmaps? Not defined in kernel or used in
586 e2fsprogs (COMPAT\_EXCLUDE\_BITMAP).
588 - Sparse Super Block, v2. If this flag is set, the SB field s\_backup\_bgs
589 points to the two block groups that contain backup superblocks
590 (COMPAT\_SPARSE\_SUPER2).
594 The superblock incompatible features field is a combination of any of the
604 - Compression (INCOMPAT\_COMPRESSION).
606 - Directory entries record the file type. See ext4\_dir\_entry\_2 below
607 (INCOMPAT\_FILETYPE).
609 - Filesystem needs recovery (INCOMPAT\_RECOVER).
611 - Filesystem has a separate journal device (INCOMPAT\_JOURNAL\_DEV).
613 - Meta block groups. See the earlier discussion of this feature
614 (INCOMPAT\_META\_BG).
616 - Files in this filesystem use extents (INCOMPAT\_EXTENTS).
618 - Enable a filesystem size of 2^64 blocks (INCOMPAT\_64BIT).
620 - Multiple mount protection. Not implemented (INCOMPAT\_MMP).
622 - Flexible block groups. See the earlier discussion of this feature
623 (INCOMPAT\_FLEX\_BG).
625 - Inodes can be used to store large extended attribute values
626 (INCOMPAT\_EA\_INODE).
628 - Data in directory entry (INCOMPAT\_DIRDATA). (Not implemented?)
630 - Metadata checksum seed is stored in the superblock. This feature enables
631 the administrator to change the UUID of a metadata\_csum filesystem
632 while the filesystem is mounted; without it, the checksum definition
633 requires all metadata blocks to be rewritten (INCOMPAT\_CSUM\_SEED).
635 - Large directory >2GB or 3-level htree (INCOMPAT\_LARGEDIR). Prior to
636 this feature, directories could not be larger than 4GiB and could not
637 have an htree more than 2 levels deep. If this feature is enabled,
638 directories can be larger than 4GiB and have a maximum htree depth of 3.
640 - Data in inode (INCOMPAT\_INLINE\_DATA).
642 - Encrypted inodes are present on the filesystem. (INCOMPAT\_ENCRYPT).
646 The superblock read-only compatible features field is a combination of any of
656 - Sparse superblocks. See the earlier discussion of this feature
657 (RO\_COMPAT\_SPARSE\_SUPER).
659 - This filesystem has been used to store a file greater than 2GiB
660 (RO\_COMPAT\_LARGE\_FILE).
662 - Not used in kernel or e2fsprogs (RO\_COMPAT\_BTREE\_DIR).
664 - This filesystem has files whose sizes are represented in units of
665 logical blocks, not 512-byte sectors. This implies a very large file
666 indeed! (RO\_COMPAT\_HUGE\_FILE)
668 - Group descriptors have checksums. In addition to detecting corruption,
669 this is useful for lazy formatting with uninitialized groups
670 (RO\_COMPAT\_GDT\_CSUM).
672 - Indicates that the old ext3 32,000 subdirectory limit no longer applies
673 (RO\_COMPAT\_DIR\_NLINK). A directory's i\_links\_count will be set to 1
674 if it is incremented past 64,999.
676 - Indicates that large inodes exist on this filesystem
677 (RO\_COMPAT\_EXTRA\_ISIZE).
679 - This filesystem has a snapshot (RO\_COMPAT\_HAS\_SNAPSHOT).
681 - `Quota <Quota>`__ (RO\_COMPAT\_QUOTA).
683 - This filesystem supports “bigalloc”, which means that file extents are
684 tracked in units of clusters (of blocks) instead of blocks
685 (RO\_COMPAT\_BIGALLOC).
687 - This filesystem supports metadata checksumming.
688 (RO\_COMPAT\_METADATA\_CSUM; implies RO\_COMPAT\_GDT\_CSUM, though
689 GDT\_CSUM must not be set)
691 - Filesystem supports replicas. This feature is neither in the kernel nor
692 e2fsprogs. (RO\_COMPAT\_REPLICA)
694 - Read-only filesystem image; the kernel will not mount this image
695 read-write and most tools will refuse to write to the image.
696 (RO\_COMPAT\_READONLY)
698 - Filesystem tracks project quotas. (RO\_COMPAT\_PROJECT)
702 The ``s_def_hash_version`` field is one of the following:
719 - Half MD4, unsigned.
725 The ``s_default_mount_opts`` field is any combination of the following:
734 - Print debugging info upon (re)mount. (EXT4\_DEFM\_DEBUG)
736 - New files take the gid of the containing directory (instead of the fsgid
737 of the current process). (EXT4\_DEFM\_BSDGROUPS)
739 - Support userspace-provided extended attributes. (EXT4\_DEFM\_XATTR\_USER)
741 - Support POSIX access control lists (ACLs). (EXT4\_DEFM\_ACL)
743 - Do not support 32-bit UIDs. (EXT4\_DEFM\_UID16)
745 - All data and metadata are commited to the journal.
746 (EXT4\_DEFM\_JMODE\_DATA)
748 - All data are flushed to the disk before metadata are committed to the
749 journal. (EXT4\_DEFM\_JMODE\_ORDERED)
751 - Data ordering is not preserved; data may be written after the metadata
752 has been written. (EXT4\_DEFM\_JMODE\_WBACK)
754 - Disable write flushes. (EXT4\_DEFM\_NOBARRIER)
756 - Track which blocks in a filesystem are metadata and therefore should not
757 be used as data blocks. This option will be enabled by default on 3.18,
758 hopefully. (EXT4\_DEFM\_BLOCK\_VALIDITY)
760 - Enable DISCARD support, where the storage device is told about blocks
761 becoming unused. (EXT4\_DEFM\_DISCARD)
763 - Disable delayed allocation. (EXT4\_DEFM\_NODELALLOC)
767 The ``s_flags`` field is any combination of the following:
776 - Signed directory hash in use.
778 - Unsigned directory hash in use.
780 - To test development code.
784 The ``s_encrypt_algos`` list can contain any of the following:
793 - Invalid algorithm (ENCRYPTION\_MODE\_INVALID).
795 - 256-bit AES in XTS mode (ENCRYPTION\_MODE\_AES\_256\_XTS).
797 - 256-bit AES in GCM mode (ENCRYPTION\_MODE\_AES\_256\_GCM).
799 - 256-bit AES in CBC mode (ENCRYPTION\_MODE\_AES\_256\_CBC).
801 Total size of the superblock is 1024 bytes.