Every change to the filesystem blocks or inodes modifies the superblock. If the CPU is halted, and the last command involving output to the filesystem is not a sync command, the superblock will almost certainly be corrupted. The superblock can be checked for inconsistencies involving:
The number of blocks in a filesystem must be greater than the number of blocks used by the superblock plus the number of blocks used by the inode list. The number of inodes must be less than the maximum number allowed for the filesystem type. While there is no way to check these sizes precisely, fsck can check that they are within reasonable bounds. All other checks of the filesystem depend on how reasonable these values are.
The free-block list starts in the superblock and continues through the free-block lists of the filesystem. Each free-block list can be checked for:
The first free-block list is in the superblock. The fsck program checks the list count for a value less than 0 or greater than 50. It also checks each block number to make sure it is within the range bounded by the first and last data block in the filesystem. Each block number is compared to a list of previously allocated blocks. If the free-block list pointer is not 0, the next free-block list is read and the process is repeated.
When all the blocks have been accounted for, the fsck program ensures that the number of blocks in the free-block list plus the number of blocks claimed by the inodes equals the total number of blocks in the filesystem. If anything is wrong with the free-block list, fsck can rebuild it leaving out blocks already allocated.
The superblock contains a count of the total number of free blocks within the filesystem. The fsck program compares this count to the number of blocks it finds free within the filesystem. If the counts do not agree, fsck can replace the count in the superblock by the actual free-block count.
The superblock contains a count of the number of free inodes within the filesystem. The fsck program compares this count to the number of inodes it found free within the filesystem. If the counts do not agree, fsck can replace the count in the superblock by the actual free inode count.