FSCK(8)

NAME
fsck - filesystem consistency check and interactive repair

SYNOPSIS
/etc/fsck -p [ filesystem ... ]
/etc/fsck [ -b block# ] [ -c ] [ -y ] [ -n ] [ filesystem ] ...

DESCRIPTION
fsck with the -p option preens (checks and repairs) a standard set of filesystems or the specified filesystems. It is normally used in the script /etc/rc during automatic reboot. In this case fsck reads the table /etc/fstab to determine which filesystems to check. It uses the information there to inspect groups of disks in parallel taking maximum advantage of I/O overlap to check the filesystems as quickly as possible. To maximize I/O overlap, fsck creates a list of partitions for each physical device to be checked. fsck tries to keep one instance of fsck active on one partition of each physical device to be checked. When one partition on a physical device has completed fsck, another partition on that device is started immediately.

The system allows a restricted class of inconsistencies unless hardware or software failures intervene. These inconsistencies are limited to the following:

    Unreferenced inodes

    Link counts in inodes too large

    Missing blocks in the free list

    Blocks in the free list also in files

    Counts in the superblock wrong

These are the only inconsistencies which fsck with the -p option will correct. If it encounters other inconsistencies, it exits with an abnormal return status and an automatic reboot then fails. For each corrected inconsistency, one or more lines are printed identifying the filesystem on which the correction will take place and the nature of the correction. After successfully correcting a filesystem, fsck prints the number of files on that filesystem, the number of used and free blocks, and the percentage of fragmentation.

Without the -p option, fsck audits and interactively repairs inconsistent conditions for filesystems. If the filesystem is inconsistent, the operator is prompted for agreement before each correction is attempted. Note that a number of the corrective actions which cannot be fixed under the -p option result in some loss of data. The amount and severity of data lost can 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 defaults to the -n option.

fsck has more consistency checks than its predecessors check, dcheck, fcheck, and icheck combined.

The following options can be specified with fsck:

-b  Use the block specified immediately after the flag as the superblock for the filesystem. Block 32 is always an alternate superblock.

-y  Assume a yes response to all questions asked by fsck. This should be used with great caution as this allows fsck to continue after essentially unlimited trouble has been encountered.

-n  Assume a no response to all questions asked by fsck; do not open the filesystem for writing.

-c  Convert the files system to the new (dynamic table) format, if it is in the old (static table) format. If the file system is in the new format, convert it to the old format provided the old format can support the filesystem configuration. In interactive mode, fsck lists the direction the conversion is to be made and asks whether the conversion should be done. If a negative answer is given, no further operations are done on the filesystem. With the -p option, the direction of the conversion is listed and done if possible without user interaction. Conversion with -p is best used when all the file systems are being converted at once. The format of a file system can be determined from the first line of output from dumpfs(8).

If no filesystems are given to fsck, a default list of filesystems is read from the file /etc/fstab.

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 filesystem.

3.  Incorrect link counts.

4.  Size checks:

    Directory size not of proper format.

5.  Bad inode format.

6.  Blocks not accounted for anywhere.

7.  Directory checks:

    File pointing to unallocated inode.
    Inode number out of range.

8.  Superblock checks:

    More blocks for inodes than there are in the filesystem.

9.  Bad free block list format.

10. Total free block and/or free inode count incorrect.

Orphaned files and directories (allocated but unreferenced) are, with the operator's agreement, reconnected by placing them in the lost+found directory. The name assigned is the inode number. If the lost+found directory does not exist, it is created. If there is insufficient space in lost+found, its size is increased.

Checking the raw device is almost always faster.

FILES

/etc/fstab
    Contains default list of filesystems to check

DIAGNOSTICS
The diagnostics produced by fsck are intended to be self-explanatory.

SEE ALSO
crash(8), dumpfs(8), mkfs(8), fs(5), fstab(5)