fsck(8) — Maintenance
OSF
NAME
fsck − Provides file system consistency check and interactive repair
SYNOPSIS
fsck [options] [file system]
fsck [common_options] [-t ufs | s5fs [fs_type_options] [file system]]
fsck [common_options] [-T ufs | s5fs [fs_type_options] [file system]]
DESCRIPTION
Since the operating system supports multiple file system types, fsck is a front-end program used to manage each file system type on your system. See the subsequent major sections of this reference page for information about using fsck for each specific file system type.
The ufs is the default file system type. If a system has only ufs file systems, no changes are needed to manage the file systems on the system.
If fsck is invoked with zero or more options (but no -t or -T options), and no file system names are specified, the file systems listed in /etc/fstab are checked. Depending on the file system types of the file systems listed in /etc/fstab, the file system type dependent fsck programs are invoked using the option list. A file system dependent fsck program is invoked only if there are file systems in /etc/fstab that are of that file system type. If the fsck program of the default file system type (ufs) fails; that is, the program terminates with a non-zero value, fsck terminates with the exit value of the default file system type fsck. This ensures that the auto-reboot dependencies such as those commonly used in the run command script continue to function. However, if a non-default file system type fsck program terminates with a non-zero value, fsck continues to execute the remaining file system type dependent fsck programs as necessary before terminating. It then returns the first non-zero exit value from the non-default file system type fsck programs.
If fsck is invoked with zero or more options (but no -t or -T options) and file systems are specifed, each file system is searched for in /etc/fstab. If it is in /etc/fstab, the listed file system type is used to determine which file system type dependent fsck program will be invoked with the supplied options on the device. If a file system is not listed in /etc/fstab, that file system will be checked using the default file system type fsck program. File systems of different file system types may be listed in any order on the command line. Each file system dependent fsck program will be invoked once with the appropriate list of file systems.
The front-end fsck program interprets the -t and -T flags. Any options specified before the -t and -T flags are common options which are passed onto all file system dependent fsck programs to be run. Options following the -t and -T flags are passed along only to the fsck programs of the specified file system types.
-t ufs | s5fsSpecifies the file system type to check. The immediately following argument is the name of the file system type. If any options follow, they are applied only in the specified file system type dependent fsck program. If any file systems follow before another -t option, the file systems are treated as of the specified file system type.
-T ufs | s5fsSpecifies to which file system type the following options apply. The immediately following argument is the name of the file system type. If any options follow, they are applied only in the specified file system type dependent fsck program. If any file systems follow, if there is a previous -t option, the file systems are treated as file systems of the file system type specified by that -t option. If there is no previous -t option, each file system is looked up in /etc/fstab to determine its file system type. If a file system is not listed in /etc/fstab, it is assumed to be a file system of the default type. ufs is the default file system type. You must be root to use this command.
EXAMPLES
Assume that /etc/fstab contains the following ufs and s5fs file systems:
•/dev/rz3c is a device listed in /etc/fstab as containing a ufs file system
•/dev/rz0c is a device listed in /etc/fstab as containing a s5fs file system
•/dev/rz1a is a device that is not listed in /etc/fstab
•ufs_fsck is the ufs fsck program
•s5fs_fsck is the fsck program that checks System V file systems.
1.To invoke the front-end fsck program which invokes the ufs_fsck and the s5fs_fsck file system dependent fsck programs (both of which check the /etc/fstab file), enter:
fsck
2.To check a specific ufs file system, a System V file system, and an unlisted file system, enter:
fsck /dev/rrz3c /dev/rrz0c /dev/rrz1a
The ufs_fsck program checks the /dev/rrz3c and /dev/rrz1a file systems. The s5fs_fsck program checks the /dev/rrz0c file system.
3.To check all ufs file systems and apply the -p flag, and to check all System V file systems and apply the -D flag, enter:
fsck -T ufs -p -T s5fs -D
The fsck program invokes the ufs_fsck program (which checks the usf file systems and applies the -p flag) and the s5fs_fsck program (which checks the System V file systems and applies the -D flag.
4.To check all ufs file systems and apply the -p flag, enter:
fsck -t ufs -p
The fsck program invokes the ufs_fsck -p command. s5fs_fsck is not invoked (although there are System V file systems listed in /etc/fstab) since only the -t ufs file system specification was given in the command line.
5.To check an unlisted System V file system, enter:
fsck -t s5fs /dev/rrz1a
The fsck program invokes s5fs_fsck which checks the /dev/rrz1a file system.
6.To check a file system which is not listed in the /etc/fstab file, enter:
fsck /dev/rrz1a
The fsck program invokes the ufs_fsck program which checks the /dev/rrz1a file system.
FILE SYSTEM DEPENDENT fsck - UFS FILE SYSTEMS
SYNOPSIS
fsck -p [-m mode]
fsck [-b block#] [-c] [-y] [-n] [-m mode] [file system ...]
DESCRIPTION
The first form of fsck preens a standard set of file systems or the specified file systems. It is normally used in the run command script during automatic reboot. Here fsck reads the /etc/fstab table to determine which file systems to check. Only partitions in fstab that are mounted “rw,” “rq” or “ro” and that have non-zero pass number are checked. File systems with pass number 1 (normally just the root file system) are checked one at a time. When pass 1 completes, all remaining file systems are checked, running one process per disk drive. The disk drive containing each file system is inferred from the longest prefix of the device name that ends in a digit; the remaining characters are assumed to be the partition designator.
The system takes care that only a restricted class of innocuous inconsistencies can happen unless hardware or software failures intervene. These inconsistencies include 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.
The preceding inconsistencies are the only ones that fsck with the −p flag corrects; if it 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 takes place, and the nature of the correction. After successfully correcting a file system, fsck prints the number of files on that file system, the number of used and free blocks, and the percentage of fragmentation.
If sent a QUIT signal, fsck finishes the file system checks, then exits with an abnormal return status that causes an automatic reboot to fail. This is useful when 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.
Without the −p option, fsck audits and interactively repairs inconsistent conditions for file systems. If the file system is inconsistent, you are prompted for concurrence before each correction is attempted. Note that some of the corrective actions which are not correctable under the −p option will 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 you to respond yes or no. If you do not have write permission on the file system fsck defaults to a −n action.
The fsck has more consistency checks than its predecessors check, dcheck, fcheck, and icheck combined.
The following flags are interpreted by fsck:
-bUses the block specified immediately after the flag as the super block for the file system. Block 32 is usually an alternate super block.
-cIf 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, convert it to the old format provided the old format can support the file system 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 file system. In preen mode, the direction of the conversion is listed and done if possible without user interaction. Conversion in preen mode 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.
-lLimits the number of parallel checks to the number specified in the following argument. By default, the limit is the number of disks, running one process per disk. If a smaller limit is given, the disks are checked round-robin, one file system at a time.
-mUses the mode specified in octal immediately after the flag as the permission bits to use when creating the lost+found directory rather than the default 1777. 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.
-nAssumes a no response to all questions asked by fsck except for “CONTINUE?”, which is assumed to be affirmative; do not open the file system for writing.
-oCauses fsck to unconditionally check the file system even if the file system’s clean byte is set.
-yAssumes a yes response to all questions asked by fsck; this should be used with great caution as this is a free license to continue after essentially unlimited trouble has been encountered.
If no file systems are given to fsck, then a default list of file systems is read from the file /etc/fstab.
Inconsistencies checked are as follows:
1.Blocks claimed by more than one inode or the free map.
2.Blocks claimed by an inode outside the range of the file system.
3.Incorrect link counts.
4.Size checks: directory size not of proper format; partially truncated file.
5.Bad inode format.
6.Blocks not accounted for anywhere.
7.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.
8.Super Block checks: more blocks for inodes than there are in the file system.
9.Bad free block map format.
10.Total free block and/or free inode count incorrect.
Orphaned files and directories (allocated but unreferenced) are, with your concurrence, 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 its size is increased.
Because of inconsistencies between the block device and the buffer cache, the raw device should always be used.
FILES
/usr/sbin/fsck
Specifies the command path
/etc/fstabContains default list of file systems to check
RELATED INFORMATION
Commands: fsdb(8), newfs(8), reboot(8)
FILE SYSTEM DEPENDENT fsck - SYSTEM V FILE SYSTEMS
SYNOPSIS
fsck [options]
fsck -T s5fs [options]
fsck -t s5fs [options] [file system]
DESCRIPTION
If there are System V file systems listed in /etc/fstab, the first and second forms of fsck cause all of these file systems to be checked.
If fsck is invoked with the -t s5fs flag but with no file systems listed, all of the System V file systems listed in /etc/fstab are checked. If a file system is listed as an argument, it will be checked as a System V file system.
The fsck command audits and interactively repairs inconsistent conditions for System V file systems. If the file system is found to be consistent, the number of files, blocks used, and blocks free are reported. If the file system is inconsistent, you are prompted for concurrence before each correction is attempted. Note that most corrective actions will result in some loss of data. The amount and severity of data loss can be determined from the diagnostic output. The default action for each correction is to wait for you to respond yes or no before any action is taken. If you do not have write permission, fsck defaults to the action of the -n option.
The fsck program interprets the following flags:
-yAssumes a "yes" response to all questions asked by fsck.
-nAssumes a "no" response to all questions asked by fsck; does not open the file system for writing.
-s[b:c]Ignores the actual free list and (unconditionally) reconstructs a new one by rewriting the super-block of the file system. The file system must be unmounted while this is done. The -s flag allows for the creation of an optimal free-list organization. If specified in the form
-sBlocks-per-cylinder:Blocks-to-skip
the provided values are used. If -s is specified without values, the values used when the file system was created are used. If these values were not specified, then a reasonable default value is used.
-SConditionally reconstructs the free list. This flag is like -sb:c except that the free list is rebuilt only if there are no discrepancies discovered in the file system. Using -S forces a no response to all questions asked by fsck. This flag is useful for forcing free list reorganization on uncontaminated file systems.
-CIf fsck cannot obtain enough memory to keep its tables, it uses a scratch file. If you specify the -C flag, the file named in the next argument is used as the scratch file, if needed. Without the -C flag, fsck prompts you for the name of the scratch file. The file chosen should not be on the file system being checked, and if it is not a special file or did not already exist, it is removed when fsck exits.
-qQuiet fsck. Do not print size-check messages. Unreferenced fifos and symlinks will silently be removed. If fsck requires it, counts in the super block will be automatically fixed and the free list salvaged.
-DDirectories are checked for bad blocks. Useful after system crashes.
-fFast check. Check block and sizes and check the free list. The free list will be reconstructed, if necessary.
The fsck program checks the following inconsistencies:
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 file system.
3.Incorrect link counts.
4.Size checks: Incorrect number of blocks, directory size not 16-byte aligned.
5.Bad inode format.
6.Blocks not accounted for anywhere.
7.Directory checks: File pointing to unallocated inoder, inode number out of range.
8.Super Block checks: More than 65536 inodes, 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 your concurrence, reconnected by placing them in the lost+found directory, if the files are nonempty. You are notified if the file or directory is or is not empty. Empty files or directories are removed, if you do not specify the -n flag. fsck forces the reconnection of nonempty directories. The name assigned is the inode number. The only restriction is that the lost+found directory must preexist in the root of the file system being checked and must have empty slots in which entries can be made. This is accomplished by making lost+found, copying a number of files to the directory, and then removing them (before fsck is executed).
Because of inconsistencies between the block device and the buffer cache, the raw device should always be used.
FILES
/usr/sbin/fsck
Specifies the command path
/etc/fstabContains the default list of System V file systems to check
RELATED INFORMATION
Commands: newfs(8)
Files: fstab(4)