Superblock (file system)

In computer file systems, a superblock is a critical metadata structure that contains information about the file system's layout, size, and status. It is used by the operating system to understand and manage the file system stored on a storage device. Without a valid superblock, the file system cannot be correctly mounted or interpreted. Usually multiple copies of the superblock are kept on the volume.{{sfn|Toolan|2025|p=}}

Overview

The superblock stores global information about the file system, such as:

  • File system size and block size
  • Number of allocation groups
  • Metadata locations
  • File system UUID and label
  • Journal configuration (if applicable)
  • Supported features and format version

While the specific structure of a superblock varies between file systems, its role as the "header" of the file system remains consistent.

XFS superblock structure

In XFS, the superblock is located at a well-known offset at the beginning of the file system (usually block 0 of AG 0), and additional copies exist at the start of each Allocation Group (AG).

The XFS superblock includes fields such as:

  • magicnum: Magic number identifying XFS
  • blocksize: Block size in bytes
  • dblocks: Total number of data blocks
  • agcount: Number of allocation groups
  • uuid: File system UUID
  • logstart: Start block of the journal (log) if internal

This structure is fixed-size and versioned, ensuring compatibility and upgrade paths across kernel versions.

Location and redundancy

XFS divides its storage into multiple allocation groups for parallelism and scalability. Each AG contains its own copy of the superblock. This design provides redundancy and allows for localized metadata operations, improving performance on large systems.

Corruption in the primary AG's superblock can sometimes be recovered by referencing the superblock from a different AG. Tools like xfs_repair and xfs_db assist in verifying or rebuilding the superblock when issues are detected.

Mounting and recovery

When an XFS file system is mounted, the superblock is read to determine critical parameters such as block size, journaling state, and AG structure. If the superblock is unreadable, the mount operation will fail.

The tool xfs_repair can attempt to reconstruct a damaged superblock using redundant copies:

xfs_repair /dev/sdX

Advanced recovery and analysis can be performed using xfs_db:

xfs_db /dev/sdX

xfs_db> sb 0

xfs_db> p

These tools help inspect or rebuild specific superblocks in alternate AGs.

Other file systems with superblocks

  • ext2, ext3, ext4{{Cite web |title=Ext4 Disk Layout - Ext4 |url=https://archive.kernel.org/oldwiki/ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout.html#The_Super_Block |access-date=2025-05-31 |website=archive.kernel.org}} – Redundant superblocks in fixed block groups
  • UFS (Unix File System) – Single primary superblock with backups

See also

References

Sources

  • {{cite book |last=Toolan |first=Fergus |title=File System Forensics |publisher=John Wiley & Sons |date=2025 |isbn=978-1-394-28979-0 |url=https://www.google.com/books/edition/File_System_Forensics/uphCEQAAQBAJ |access-date=2025-06-01}}
  • {{cite book |last=Toolan |first=Fergus |title=File System Forensics |publisher=John Wiley & Sons |date=2025a |isbn=978-1-394-28979-0 |chapter-url=https://www.google.com/books/edition/File_System_Forensics/uphCEQAAQBAJ?hl=en&gbpv=1&pg=PA201 |access-date=2025-06-01|chapter=The Superblock [ext]}}
  • {{cite book |last=Toolan |first=Fergus |title=File System Forensics |publisher=John Wiley & Sons |date=2025b |isbn=978-1-394-28979-0 |chapter-url=https://www.google.com/books/edition/File_System_Forensics/uphCEQAAQBAJ?hl=en&gbpv=1&pg=PA268 |access-date=2025-06-01|chapter=The Superblock [XFS]}}
  • {{cite book |last=Toolan |first=Fergus |title=File System Forensics |publisher=John Wiley & Sons |date=2025c |isbn=978-1-394-28979-0 |chapter-url=https://www.google.com/books/edition/File_System_Forensics/uphCEQAAQBAJ?hl=en&gbpv=1&pg=PA305 |access-date=2025-06-01|chapter=The Superblock [btfrs]}}