Content-type: text/html Man page of fsck

fsck

Section: Maintenance Commands (8)
Index Return to Main Contents
 

NAME

fsck, ufs_fsck - Check and repair UFS file systems  

SYNOPSIS

/usr/sbin/fsck [fs_options] [filesystem...]  

DESCRIPTION

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.

If you specify a file system, the raw device should always be used because of inconsistencies between the block device and the buffer cache.

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.

If you have a file system erroneously labeled Advfs and it overlaps a file system labeled UFS (or one of the UFS variants), an error results. You can recover from this error by changing the erroneously-labeled file system's fstype filed from advfs to unused with the disklabel -s command. After changing the disk label, run the fsck command.

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:

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

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 diagnostic output.

When the system boots, the fsck program is automatically run with the -p flag. The program reads the /etc/fstab file to determine which file systems to check. Only partitions that are specified in the fstab file as being mounted ``rw'' or ``ro'' and that have a non-zero pass 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, all the remaining file systems are checked, with one process running per disk drive.

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.  

FLAGS

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. 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 interaction 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. 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 specified 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.  

ERRORS

The following message indicates that the system is avoiding a potential panic by skipping the file system check:

/dev/rrz2g: skipping filesystem already mounted (read-write) on '/usr'

The following message indicates that the file system is mounted:

/dev/rz2g on /usr: Device busy

The following message indicates that the partition you are checking is open:

ERROR: /dev/rrz3a or an overlapping partition is open
fsck cannot be run on an active filesystem  

EXAMPLES

The following is an example of an /etc/fstab file that is used in the examples in this section: /dev/rz2a      /       ufs rw 1 1
/dev/rz0g       /usr    ufs rw 1 2
/dev/rz2b       swap1   ufs sw 0 2
/dev/rz0b       /public ufs sw 0 2
/dev/rz2g       /var    ufs rw 1 2
/dev/rz3c       /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/rrz3c /dev/rrz1a

The following command noninteractively checks the file systems in the /etc/fstab file: # fsck -p  

FILES

Specifies the command path Specifies the command path Contains the default list of file systems to check  

RELATED INFORMATION

Commands: newfs(8) delim off


 

Index

NAME
SYNOPSIS
DESCRIPTION
FLAGS
ERRORS
EXAMPLES
FILES
RELATED INFORMATION

This document was created by man2html, using the manual pages.
Time: 02:40:39 GMT, October 02, 2010