NAME
fsck_ffs —
Fast File System consistency
check and interactive repair
SYNOPSIS
fsck_ffs |
[-adFfPpqUX]
[-B
byteorder]
[-b block]
[-c level]
[-m mode]
[-x
snap-backup]
[-y | -n]
filesystem ... |
DESCRIPTION
fsck_ffs performs interactive file system consistency checks
and repair for each of the file systems specified on the command line. 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
large
- Missing blocks in the free
map
- Blocks in the free map also in
files
- Counts in the super-block
wrong
These are the only inconsistencies that
fsck_ffs in
“preen” mode (with the
-p option) 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 system,
fsck_ffs will print 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_ffs will
finish the file system checks, then exit with an abnormal return status.
If
fsck_ffs receives a
SIGINFO
signal
(see the
status argument for
stty(1)), a line will be written
to the standard error output indicating the name of the device currently being
checked, the current phase number and phase-specific progress information.
Without the
-p option,
fsck_ffs audits and
interactively repairs inconsistent conditions for file systems. 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
fsck_ffs will default to a
-n action.
fsck_ffs has more consistency checks than its predecessors
check,
dcheck,
fcheck,
and
icheck combined.
The following flags are interpreted by
fsck_ffs.
-
-
- -a
- Interpret the filesystem as an Apple UFS filesystem, even
if there is no Apple UFS volume label present.
-
-
- -B
byteorder
- Convert the file system metadata to
byteorder byte order if needed. Valid byte orders
are “be” and “le”. If fsck_ffs
is interrupted while swapping the metadata byte order, the file system
cannot be recovered. fsck_ffs will print a message in
interactive mode if the file system is not in host byte order.
-
-
- -b
block
- Use the block number block as the
super block for the file system. Block 32 is usually an alternative super
block. The -b option of the
scan_ffs(8) utility can
also be used to find the offset of other super block backups in a file
system.
-
-
- -c
level
- Convert the FFSv1 file system to the level
level. Note that the level of a file system can only
be raised. There are currently five levels defined:
-
-
- 0
- The file system is in the old (static table)
format.
-
-
- 1
- The file system is in the new (dynamic table) format.
Such file systems are made by using the -O
0 option to
newfs(8).
-
-
- 2
- The file system supports 32-bit UIDs and GIDs, short
symbolic links are stored in the inode, and directories have an added
field showing the file type. This format was introduced in
4.4BSD.
-
-
- 3
- If maxcontig is greater than one, build the free
segment maps to aid in finding contiguous sets of blocks. If maxcontig
is equal to one, delete any existing segment maps. This was the
default before NetBSD 2.0.
-
-
- 4
- Rearrange the super block to the same layout as FFSv2;
disable the rotational layout tables and per cylinder group block
totals. Such file systems are made by using the -O
1 option to
newfs(8).
Note that FFSv2 file systems are always level 4.
In interactive mode, fsck_ffs will list the conversion to
be made and ask 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 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 output of dumpfs(8) can be
examined to determine the format of the file system (“format”
in the second line) and the file system level (“fslevel” in
the sixth line).
-
-
- -d
- Print debugging output.
-
-
- -F
- Indicates that filesystem is a file
system image, rather than a raw character device.
filesystem will be accessed ‘as-is’, and
no attempts will be made to read a disklabel.
-
-
- -f
- Force checking of file systems. Normally, if a file system
is cleanly unmounted, the kernel will set a “clean flag” in
the file system super block, and fsck_ffs will not check
the file system. This option forces fsck_ffs to check
the file system, regardless of the state of the clean flag.
-
-
- -m
mode
- Use the octal value mode as the
permission bits to use when creating the lost+found
directory rather than the default 1700. 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.
-
-
- -n
- Assume a no response to all questions asked by
fsck_ffs except for
‘
CONTINUE?
’, which is assumed to be
affirmative; do not open the file system for writing.
-
-
- -P
- Display a progress meter for the file system check. A new
meter is displayed for each of the 5 file system check passes, unless
-p is specified, in which case only one meter for
overall progress is displayed. Progress meters are disabled if the
-d option is specified.
-
-
- -p
- Specify “preen” mode, described above.
-
-
- -q
- Quiet mode, do not output any messages for clean
filesystems.
-
-
- -U
- Resolve user ids to usernames.
-
-
- -X
- Similar to -x but uses a file system
internal snapshot on the file system to be checked.
-
-
- -x
snap-backup
- Use a snapshot with snap-backup as
backup to check a read-write mounted filesystem. Must be used with
-n. See
fss(4) for more details. The
point is to check an internally-consistent version of the filesystem to
find out if it is damaged; on failure one should unmount the filesystem
and repair it.
-
-
- -y
- Assume a yes response to all questions asked by
fsck_ffs; this should be used with great caution as this
is a free license to continue after essentially unlimited trouble has been
encountered.
Inconsistencies checked are as follows:
- 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 a
multiple of DIRBLKSIZ.
- 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.
Orphaned files and directories (allocated but unreferenced) are, with the
operator's 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.
DIAGNOSTICS
The diagnostics produced by
fsck_ffs are fully enumerated and
explained in Appendix A of
Fsck - The UNIX
File System Check Program.
SEE ALSO
fss(4),
fs(5),
fstab(5),
dumpfs(8),
fsck(8),
fsdb(8),
newfs(8),
reboot(8),
scan_ffs(8)
HISTORY
A
fsck utility appeared in
4.0BSD. It
was renamed to
fsck_ffs in
NetBSD
1.3 with the introduction of a filesystem independent wrapper as
fsck.