|
|
The most commonly corrupted item in a filesystem is the summary information associated with the superblock, because it is modified with every change to the blocks or inodes of the filesystem, and is usually corrupted after an unclean halt. The superblock is checked for inconsistencies involving:
The filesystem size must be larger than the number of blocks used by the superblock and the number of blocks used by the list of inodes. While there is no way to check these sizes precisely, fsck can check that they are within reasonable bounds. All other filesystem checks require that these sizes be correct. If fsck detects corruption in the static parameters of the default superblock, fsck requests the operator to specify the location of an alternate superblock.
fsck checks that all the blocks marked as free in the cylinder group block maps are not claimed by any files. When all the blocks have been initially accounted for, fsck checks that the number of free blocks plus the number of blocks claimed by the inodes equals the total number of blocks in the filesystem. If anything is wrong with the block allocation maps, fsck will rebuild them, based on the list it has computed of allocated blocks.
The summary information associated with the superblock contains a count of the total number of free blocks within the filesystem. fsck compares this count to the number of free blocks it finds within the filesystem. If the two counts do not agree, fsck replaces the incorrect count in the summary information by the actual free block count.
The summary information contains a count of the total number of free inodes within the filesystem. fsck compares this count to the number of free inodes it finds within the filesystem. If the two counts do not agree fsck replaces the incorrect count in the summary information by the actual free inode count.