fsck(8) System Manager's Manual fsck(8)
fsck - check and repair file system
/etc/fsck [ -p -P ] [ filesystem ... ]
/etc/fsck [ -b block ] [ -y ] [ -n ] [ filesystem ] ...
The command checks and corrects either a standard set of file systems or the specified file systems for consistency. This command is nor-
mally used in the script during automatic reboot. In this case, reads the file to determine which UFS file systems to check. It uses the
information to inspect groups of disks in parallel, taking advantage of I/O overlap to check the file systems as quickly as possible.
The 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 file systems such as partition are checked on pass 2, and other small file systems are checked on separate passes. For example, the
file systems are usually checked on pass 3 and the file systems are usually checked on pass 4. The large user file systems are usually
checked on the final pass. A pass number of 0 in causes a disk to not be checked. Similarly, partitions that are not shown to be mounted
with or are not checked.
The option should be used to check file systems. The generic file system interface, causes to realize when a file system is unmounted
cleanly and thus prevents from doing the check. File systems are unmounted cleanly only when an error-free shutdown has been performed or
the file system was unmounted. However, a timeout factor is used by to determine if should be run regardless of the value of the clean
byte. The timeout factor is initially set to 20 and is decremented when any one of three events occur:
- A file system is mounted,
- 10,000 updates have occurred
- A file system was updated and occurred more than 60 days prior
When the timeout factor reaches 0, will automatically check it. This factor can be changed with If the option is used, the parallel con-
sistency checks are performed like the option regardless of how the file system was unmounted.
If an attempt is made to check a mounted file system using the block device, will report filesystem: and will check the filesystem as if
the option is selected.
The system ensures that only a restricted class of file system inconsistencies can occur unless hardware or software failures intervene.
The inconsistencies are limited to:
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 superblock are wrong
These are the only inconsistencies that corrects with either the or option. If 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 are printed identifying the file
system on which the correction will take place and the nature of the correction. If any inconsistencies occur, the message is printed and
runs again to verify that the appropriate changes were made. After correcting a file system, prints the number of files on that file sys-
tem and the number of used and free blocks and also the percent of fragments vs blocks. When the fragmentation exceeds 5% it is recom-
mended that the file system be dumped to tape, and restored. Also, a clean byte is set for the checked file system. The root file system
is checked regardless of whether the clean byte is set.
Without the or options, audits and interactively repairs inconsistent conditions for file systems. If the file system is inconsistent, the
operator is prompted before each correction is attempted. It should be noted that a number of the corrective actions which are not fixable
using the or 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 or If the operator does not have write permis-
sion, defaults to a action.
If no file systems are given to then a default list of file systems is read from the file The command only checks file systems of type UFS.
The command checks for the following inconsistencies:
Blocks claimed by more than one inode or the free list.
Blocks claimed by an inode or the free list outside the range of the file system.
Incorrect link counts.
Size checks; directory size not of proper format.
Bad inode format.
Blocks not accounted for.
Directory checks; file pointing to unallocated inode; inode number out of range.
Superblock checks; more blocks for inodes than there are in the file system.
Bad free block list format.
Total free block or free inode count incorrect.
If detects allocated but unreferenced files and directories, it prompts you before placing them in the directory. The only restriction is
that the directory must exist in the root of the file system being checked and must have empty slots before is run. If necessary, the
directory can be enlarged by creating many files in the directory and then removing them.
General users can run on file systems with certain restrictions. The user must have execute permissions on the device and general users
cannot run on a mounted file system.
-b Use the block specified immediately after the flag as the superblock for the file system. Block 32 is always an alternate
-y Assume a response to all questions asked by this should be used with caution as this allows to continue after essentially unlimited
trouble has been encountered.
-n Assume a response to all questions asked by do not open the file system for writing.
-p Check a file system that was not unmounted cleanly.
-P Check a file system regardless of how it was unmounted.
Inode numbers for and in each directory should be checked for validity. The command will not allow checking a raw device if the block
device is mounted.
Contains default list of file systems to check
getmnt(2), fstab(5), ufs(5), crash(8v), mkfs(8), mklost+found(8), mount(8), mount(8ufs), newfs(8), reboot(8), tunefs(8)