fsck(8)
NAME
fsck − file system consistency check and interactive repair utility.
SYNTAX
/etc/fsck [ −p|−P ] [ filesystem ... ]
/etc/fsck [ −b block# ] [ −y ] [ −n ] [ filesystem ] ...
DESCRIPTION
The fsck command checks and corrects either a standard set of filesystems or the specified file systems for consistency. This command is normally used in the script /etc/rc during automatic reboot. In this case, fsck reads the /etc/fstab table to determine which file systems to check. It uses the fstab information to inspect groups of disks in parallel, taking advantage of i/o overlap to check the file systems as quickly as possible.
The fsck command makes a number of passes to check the file systems for consistency. Usually, the root file system is checked on pass 1, other root (partition a) file systems on pass 2, other small file systems on separate passes (for example, the d file systems on pass 3 and the e file systems on pass 4), and the large user file systems on the final pass. A pass number of 0 in /etc/fstab causes a disk to not be checked. Similarly, partitions which are not shown to be mounted rw or ro are not checked.
The −p option should be used to check filesystems since now with the generic file system interface, gfsi(5), fsck realizes when a file system is unmounted cleanly and does not do the check. File systems are unmounted cleanly only when an error-free shutdown has been performed. If the −P option is used, the parallel consistency checks are performed like the −p option regardless of how the file system was unmounted, cleanly or otherwise.
The system ensures that only a restricted class of filesystem inconsistencies can occur unless hardware or software failures intervene. The inconsistencies are limited to:
Unreferenced inodes
Link counts in inodes are too large
Missing blocks in the free list
Blocks in the free list are also in files
Counts in the super-block are wrong
These are the only inconsistencies that fsck with either the −p or −P option will correct. If it encounters other inconsistencies, it exits with an abnormal return status and an automatic reboot will then fail. For each corrected inconsistency one or more lines will be printed identifying the file system on which the correction will take place, and the nature of the correction. If any inconsistencies occur, the message "**** FILE SYSTEM MODIFIED, VERIFYING" is printed and fsck runs again to verify that the appropriate changes were made. After successfully correcting a file system, fsck will print the number of files on that file system and the number of used and free blocks. Also, a clean byte is set for the checked file system, except the root, indicating that the file system is clean.
Without the −p or −P options, fsck audits and interactively repairs inconsistent conditions for file systems. If the file system is inconsistent the operator is prompted for concurrence before each correction is attempted. It should be noted that a number of the corrective actions which are not fixable using the −p or −P options will result in some loss of data. The amount and severity of data lost may be determined from the diagnostic output. The default action for each consistency correction is to wait for the operator to respond yes or no. If the operator does not have write permission fsck will default to a −n action.
If no filesystems are given to fsck then a default list of file systems is read from the file /etc/fstab. The fsck command will only check file systems of type ufs.
Inconsistencies checked are as follows:
1. Blocks claimed by more than one inode or the free list.
2. Blocks claimed by an inode or the free list outside the range of the file system.
3. Incorrect link counts.
4. Size checks:
Directory size not of proper format.
5. Bad inode format.
6. Blocks not accounted for.
7. Directory checks:
File pointing to unallocated inode.
Inode number out of range.
8. Super Block checks:
More blocks for inodes than there are in the file system.
9. Bad free block list format.
10. Total free block and/or free inode count incorrect.
Allocated but unreferenced files and directories are reconnected by placing them in the lost+found directory with the operator’s concurrence. The name assigned is the inode number. The only restriction is that the directory lost+found must preexist in the root of the filesystem being checked and must have empty slots in which entries can be made. This is accomplished by making lost+found, copying a number of files to the directory, and then removing them before fsck is executed.
OPTIONS
−b Use the block specified immediately after the flag as the super block for the file system. Block 32 is always an alternate super block.
−y Assume a yes response to all questions asked by fsck; this should be used with great caution as this is a free license to continue after essentially unlimited trouble has been encountered.
−n Assume a no response to all questions asked by fsck; do not open the file system for writing.
−p Check a file system that was unmounted cleanly for consistency.
−P Check a file system for consistency regardless of how it was unmounted.
RESTRICTIONS
Inode numbers for . and .. in each directory should be checked for validity. The fsck command will not allow checking a raw device if the block device is mounted.
FILES
/etc/fstab contains default list of file systems to check.
SEE ALSO
getmnt(2), fstab(5), ufs(5), crash(8v), mkfs(8), mklost+found(8), mount(8), newfs(8), reboot(8)