fsck(8) System Manager's Manual fsck(8)
fsck, ufs_fsck - Check and repair UFS file systems
/usr/sbin/fsck [fs_options] [filesystem...]
The fsck command is a front-end program for the ufs_fsck program, which checks and repairs UFS file systems. Do not use this command for
AdvFS file systems: instead, see advfs(4).
The fsck program has more consistency checks than its check, dcheck, fcheck, and icheck predecessors combined.
You must be root to use this command.
If you do not specify a file system in the command line, the fsck command checks the file systems in the /etc/fstab file.
With one exception, the fsck command cannot be used on an active file system. The command checks to determine whether the partition to be
checked, or an overlapping partition, is in use. The exceptional case occurs when you run the command on an active root file system and
specify the -f flag. Use this flag with caution, because it can cause the data on the running system (the in-memory data) to become unsyn-
chronized from the file system data (the on-disk data).
The fsck program interactively repairs inconsistent file system conditions. If the file system is found to be consistent, the number of
files, blocks used, and free blocks are reported. If the file system is inconsistent, you are prompted before each correction is
attempted. For each corrected inconsistency, one or more lines are displayed, identifying the file system on which the correction takes
place and the type of correction. After successfully correcting a file system, the fsck program displays the number of files on that file
system, the number of used and free blocks, and the percentage of fragmentation.
The default behavior of the fsck program is to interactively check the following UFS file system inconsistencies:
Blocks claimed by more than one inode or the free map
Blocks claimed by an inode outside the range of the file system
Incorrect link counts
Size checks: directory size not of proper format; partially truncated file
Bad inode format
Blocks not accounted for anywhere
Directory checks: file pointing to unallocated inode; inode number out of range; . (dot) or .. (dot dot) not the first two entries of a
directory or having the wrong inode number
Super Block checks: more blocks for inodes than there are in the file system
Bad free block map format
Total free block and/or free inode count incorrect
If you use the -p flag, the fsck program noninteractively attempts to correct specific file system inconsistencies. The corrections are
made only if they can be done safely. The fsck program can noninteractively correct the following file system inconsistencies:
Link counts in inodes that are too large
Missing blocks in the free map
Blocks in the free map that are also in files
Wrong counts in the super-block.
If fsck encounters any other inconsistencies, it exits with an abnormal return status and a subsequent reboot will fail.
The system makes sure that only a restricted class of innocuous inconsistencies can occur unless hardware or software failures intervene.
Note that some of the corrective actions can result in a loss of data. The amount and severity of data lost can be determined from the
At system boot, fsck -p runs automatically and reads the /etc/fstab file to determine which file systems to check. Only partitions that
are mounted rw or ro and have a non-zero pass (1 or more) number are checked. File systems that have a pass number 1 (usually only the
root file system) are checked one at a time. When pass 1 completes, the remaining pass numbers are processed with one parallel fsck
process running per disk drive in the same pass.
The per disk drive logic is based on the /dev/disk/dsk0a syntax where different partition letters are treated as being on the same disk
drive. Partitions layered on top of an LSM device may not follow this naming convention. Where LSM is used, you can use unique pass num-
bers in the /etc/fstab file to sequence the fsck checks.
If a QUIT signal is sent, fsck finishes the file system checks and then exits with an abnormal return status that causes the automatic
reboot to fail. This is useful if you want to finish the file system checks during an automatic reboot but do not want the machine to come
up multiuser after the checks complete.
If the fsck default program fails (terminates with a non-zero value), fsck terminates with the exit value. This ensures that the auto-
reboot dependencies, such as those commonly used in the run command script, continue to function.
If orphaned files or directories (allocated but unreferenced) are found, you are asked if you want to reconnect the files and directories
that are not empty by putting them in the lost+found directory. The program indicates whether the file or directory is empty or not empty.
The fsck program reconnects directories that are not empty and assigns the inode number for the name. If the lost+found directory does not
exist, it is created, and if it has insufficient space, the size is increased. Empty files and directories are removed unless you specify
the -n flag.
The following flags are interpreted by fsck: Uses the specified block number as the super block for the file system. Block 32 is usually
an alternate super block. Converts UFS Version 4 back to UFS Version 3. When you use the -B option on a UFS Version 4 file system, it will
be marked as a Version 3 file system if there are no files or directories with more than 32767 hardlinks or 32765 subdirectories. If the
file system is in the old (static table) format, converts it to the new (dynamic table) format. If the file system is in the new format,
this flag converts it to the old format, provided that the old format can support the file system configuration. In interactive mode, fsck
lists the direction of the conversion and asks if the conversion should be done. If you answer "no," no further operations are done on the
file system. If the -p flag is specified, the direction of the conversion is listed and the conversion is performed without user interac-
tion if possible. The -p flag should be used if all the file systems are being converted simultaneously. The format of a file system can
be determined from the first line of output from the dumpfs command. Forces fsck to check the root file system, even when the file system
is mounted as writable. Use this flag with caution, because running fsck on a mounted root file system can cause its files to become out
of synchronization with running system data. If the problem occurs, the fsck program displays a message recommending you reboot the sys-
tem. Limits the number of parallel checks to the number specified. By default, the limit is the number of disks running one process per
disk. If a smaller limit is given, the disks are checked using a round robin-type schedule, one file system at a time. Uses the mode spec-
ified in octal as the permission bits to use when creating the lost+found directory rather than the default 777. In particular, systems
that do not want to have lost files accessible by all users on the system should use a more restrictive set of permissions, such as 700.
Answers "no" to all the prompts except for the ``CONTINUE?'' prompt. The flag does not write to the lost+found file in the file system.
If you do not have write permission on the file system, fsck defaults to the behavior of the -n flag. Causes fsck to unconditionally check
the file system even if the file system's clean byte is set. That is, a file system is checked even if it has been unmounted cleanly.
Noninteractively corrects the following file system inconsistencies: unreferenced inodes, link counts in inodes that are too large, missing
blocks in the free map, blocks in the free map that are also in files, and wrong counts in the super-block. Causes more extensive messages
to be displayed during the file system checks (verbose mode). Answers "yes" to all the prompts. This flag should be used with caution
because the integrity of the file system data can be corrupted by answering "yes" to all the prompts.
The following message indicates that the system is avoiding a potential panic by skipping the file system check:
/dev/disk/dsk2g: skipping filesystem already mounted (read-write) on '/usr'
The following message indicates that the file system is mounted:
/dev/disk/dsk2g on /usr: Device busy
The following message indicates that the partition you are checking is open:
ERROR: /dev/rdisk/dsk3a or an overlapping partition is open
fsck cannot be run on an active filesystem
The following is an example of an /etc/fstab file that is used in the examples in this section: /dev/disk/dsk2a / ufs rw 1 1
/dev/disk/dsk0g /usr ufs rw 1 2 /dev/disk/dsk2b swap1 ufs sw 0 2 /dev/disk/dsk0b /public ufs sw 0 2 /dev/disk/dsk2g
/var ufs rw 1 2 /dev/disk/dsk3c /usr/users ufs rw 1 2
The following command checks all the file systems in the /etc/fstab file but makes no corrections: # fsck -n
The following example checks a file system found in the /etc/fstab file and checks a file system that is not found in the /etc/fstab file:
# fsck /dev/rdisk/dsk3c /dev/rdisk/dsk1a
The following command noninteractively checks the file systems in the /etc/fstab file: # fsck -p
Specifies the command path Specifies the command path Contains the default list of file systems to check
Commands: newfs(8) delim off