Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getmnt(2)

fstab(5)

ufs(5)

crash(8v)

mkfs(8)

mklost+found(8)

mount(8)

mount(8ufs)

newfs(8)

reboot(8)

fsck(8)

NAME

fsck − check and repair file system

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 file systems 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 file to determine which UFS 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 file systems such as partition a are checked on pass 2, and other small file systems are checked on separate passes. For example, the d file systems are usually checked on pass 3 and the e 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 /etc/fstab causes a disk to not be checked. Similarly, partitions that are not shown to be mounted with rw or ro are not checked.

The −p option should be used to check file systems. The generic file system interface, gfsi, causes fsck to realize when a file system is unmounted cleanly and thus prevents fsck from doing the check. File systems are unmounted cleanly only when an error-free shutdown has been performed or the file system was unmounted. If the −P option is used, the parallel consistency checks are performed like the −p option regardless of how the file system was unmounted. 

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:

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 superblock are wrong

These are the only inconsistencies that fsck corrects with either the −p or −P option.  If fsck 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 “**** FILE SYSTEM MODIFIED, VERIFYING” is printed and fsck runs again to verify that the appropriate changes were made. After correcting a file system, fsck prints 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. The root file system is checked regardless of whether the clean byte is set.

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 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 defaults to a −n action. 

If no file systems are given to fsck, then a default list of file systems is read from the file /etc/fstab. The fsck command only checks file systems of type UFS.

Inconsistencies checked are as follows:

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. 

Super Block 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 fsck detects allocated but unreferenced files and directories, it prompts you before placing them in the lost+found directory. The only restriction is that the directory lost+found must exist in the root of the file system being checked and must have empty slots before fsck is run. If necessary, the lost+found directory can be enlarged by creating many files in the directory and then removing them.

General users can run fsck on file systems with certain restrictions. The user must have execute permissions on the device and general users cannot run fsck on a mounted file system.

OPTIONS

−bUse the block specified immediately after the flag as the superblock for the file system.  Block 32 is always an alternate superblock. 

−yAssume a yes response to all questions asked by fsck; this should be used with caution as this allows fsck to continue after essentially unlimited trouble has been encountered.

−nAssume a no response to all questions asked by fsck; do not open the file system for writing.

−pCheck a file system that was not unmounted cleanly. 

−PCheck a file system 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), mount(8ufs), newfs(8), reboot(8)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026