Second Extended File System consistency check and
performs interactive file system
consistency checks and repairs the filesystem specified. It is normally
invoked from fsck(8)
The kernel takes care that only a restricted class of innocuous file system
inconsistencies can happen unless hardware or software failures intervene.
These are limited to the following:
- Unreferenced inodes
- Link counts in inodes too
- Missing blocks in the free
- Blocks in the free map also in
- Counts in the super-block
These are the only inconsistencies that fsck_ext2fs
in “preen” mode (with the -p
will correct; if it encounters other inconsistencies, it exits with an
abnormal return status. For each corrected inconsistency one or more lines
will be printed identifying the file system on which the correction will take
place, and the nature of the correction. After successfully correcting a file
will print the number of
files on that file system and the number of used and free blocks.
If sent a
will finish the file system checks,
then exit with an abnormal return status.
Without the -p
audits and interactively repairs
inconsistent conditions for the filesystem. If the file system is
inconsistent, the operator is prompted for concurrence before each correction
is attempted. It should be noted 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 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 on the file system,
will default to a
The following flags are interpreted by fsck_ext2fs
- Use the block specified immediately after the flag as the
super block for the file system. Block 8193 is usually an alternate super
- Print debugging output.
- Force checking of the filesystem. Normally, if a file
system is cleanly unmounted, the kernel will set a “clean
flag” in the file system superblock and
fsck_ext2fs will not check the file system.
This option forces fsck_ext2fs to check the
file system, regardless of the state of the clean flag.
- Use the mode specified in
octal as the permission bits to use when creating the
lost+found directory rather than the default
1777. In particular, systems that do not wish to have lost files
accessible by all users on the system should use a more restrictive set of
permissions such as 700.
- Assume a “no” response to all questions asked
by fsck_ext2fs except for
“CONTINUE?”, which is assumed to be affirmative. The
filesystem will not be opened for writing. This is the default for file
systems to be checked that are concurrently mounted writable.
- Specify “preen” mode, described above.
- Assume a “yes” response to all questions asked
by fsck_ext2fs; this should be used with
great caution as this is a free license to continue after essentially
unlimited trouble has been encountered.
If neither of the -y
options are specified, the user may force
to assume an answer of
“yes” to all the remaining questions by replying to a question
with a value of “F”.
Inconsistencies checked are as follows:
- Blocks claimed more than once
by inodes or the free map.
- Blocks claimed by an inode
outside the range of the file system.
- Incorrect link counts.
- Size checks:
- Directory size not a
multiple of file system block size.
- Partially truncated
- Bad inode format.
- Blocks not accounted for
- Directory checks:
- File pointing to
- Inode number out of
- Dot or dot-dot not the
first two entries of a directory or having the wrong inode
- Super Block checks:
- More blocks for inodes
than there are in the file system.
- Bad free block map
- Total free block and/or
free inode count incorrect.
Orphaned files and directories (allocated but unreferenced) are, with the
operator's concurrence, reconnected by placing them in the
directory. The name assigned is the
inode number. If the lost+found
not exist, it is created. If there is insufficient space its size is
Because of inconsistencies between the block device and the buffer cache, the
raw device should always be used.
The diagnostics produced by fsck_ext2fs
enumerated and explained in Appendix A of
Fsck_ffs - The UNIX File System