fsck_hfs: fsck - HFS file system consistency check and interactive
The command audits and repairs inconsistent conditions for HFS file
systems on mass storage device files identified by special. If the
file system is consistent, the number of files on that file system and
the number of used and free blocks are reported. If the file system is
inconsistent, provides a mechanism to fix these inconsistencies,
depending on which form of the command is used.
special represents a special device (for example,
If the target device is a swap device, does not continue to process.
also checks the target device to ensure a mounted file system is not
being checked. If a mounted device is specified but the and options
are omitted, prompts the user for a response.
If the option is used and special is not specified, reads the pass num‐
bers in to determine which groups of disks to inspect in parallel, tak‐
ing maximum advantage of I/O overlap to process the file systems as
quickly as possible. The option is normally used in the script during
Normally, the root file system is checked on pass 1, and other "root"
(section 0) file systems on pass 2. Other small file systems are
checked on separate passes (such as the section 4 file systems on pass
3 and the section 7 file systems on pass 4), and finally the large user
file systems are checked on the last pass (for example, pass 5). A
pass number of 0 in causes a file system not to be checked. If the
optional fields are not present on a line in processes the file system
on such lines sequentially after all eligible file systems with posi‐
tive pass numbers have been processed.
The inconsistencies that with the option corrects are shown below.
These are inconsistencies that are correctable without data loss. If
it encounters other inconsistencies, it exits with an abnormal return
status. For each corrected inconsistency, one or more lines are
printed identifying the file system on which the correction will take
place and the nature of the correction. Correctable inconsistencies
are limited to the following:
· Unreferenced inodes
· Unreferenced continuation inodes
· Unreferenced pipes and FIFOs
· Link counts in inodes too large
· Missing blocks in the free list
· Blocks in the free list also in files
· Counts in the superblock wrong.
The option operates in the same manner as the option except that
cleanly unmounted file systems are not checked (see fsclean(1M)). This
can greatly decrease the amount of time required to reboot a system
that was brought down cleanly.
If the option is not specified, the pass numbers are ignored and the
file systems are checked interactively in the order they are listed in
Without the option, prompts for concurrence before each correction is
attempted when the file system is inconsistent. It should be noted
that some corrective actions result in a loss of data. The amount and
severity of data loss can be determined from the diagnostic output.
The default action for each consistency correction is to wait for the
operator to respond or If the operator does not have write permission,
defaults to a action.
recognizes the following options:
HFS file system.
Set the size of the buffer cache which
uses to cache disk blocks. size is the number of
cache blocks, and is between 0 and 100 inclusive. The
most common use of this option is to disable all
caches, thus reducing memory usage.
Use the specified
blocknum as the superblock for the file system. An
alternate superblock can usually be found at block
typically block 16. is defined in You can also find a
list of alternate superblocks in (see mkfs(1M)).
Force to check a mounted file system.
Ignore (that is, do not check) mounted file systems.
This option does not ask the user whether to check the
mounted file systems or not. Instead it simply
ignores the mounted file systems and does not check
them. If the option is specified with the option,
then the option takes precedence; that is, the is
skipped on mounted file systems in this case.
Perform a sanity check only.
Verify whether special is mounted, or needs additional
checking. Refer to the section for more information.
Assume a response to all questions asked by about repairing a
file system. Do not open the file system for writing.
"Preen" the file system.
Proceed to process and repair file systems without
user interaction, as described above. Exit immedi‐
ately if there is a problem requiring intervention.
Same as except that cleanly unmounted file systems are not
Quiet. Do not print size-check messages in Phase 1. Unrefer‐
enced fifos are silently removed. If requires it,
counts in the superblock and cylinder groups are auto‐
Safe performance mode. To improve performance, a system wide
will not be issued.
Echo the completed command line, but perform no other actions.
The command line is generated by incorporating the
user-specified options and other information derived
from This option allows the user to verify the command
Assume a response to all questions asked by about repairing a
file system. This should be used with great caution,
because this is a free license to continue after
essentially unlimited trouble has been encountered.
In all cases, checks the following inconsistencies:
· Blocks claimed by more than one inode or the free list.
· Blocks claimed by an inode or the free list outside the range of
the file system.
· Incorrect link counts.
· Size checks:
− Directory size not of proper format.
· Bad inode format.
· Blocks not accounted for anywhere.
· Directory checks:
− File pointing to unallocated inode.
− Inode number out of range.
· Superblock checks:
− More blocks for inodes than there are in the file system.
· Bad free block list format.
· Total free block and/or free inode count incorrect.
· Invalid continuation inode number in a primary inode.
Orphaned files and directories (allocated but unreferenced) are, with
the operator's concurrence, reconnected by placing them in the direc‐
tory. The name assigned is the inode number. The only restriction is
that the directory must have empty slots in which entries can be made.
This is accomplished by copying a number of files to the directory,
then removing them before is executed.
Unreferenced continuation inodes are removed with the option, since
they do not refer back to the primary inode. When a primary inode con‐
tains an invalid continuation inode number, the continuation inode num‐
ber should be cleared (that is, set to 0). This is not done automati‐
cally (with the option), because access control list information may
have been lost and should be corrected.
After has checked and fixed the file system, it stores the correct flag
in the superblock if it is not already there. For a nonroot file sys‐
tem, is stored there. For the root file system, which is mounted at
the time of the no changes are required to the superblock if no prob‐
lems were found and was already set.
Checking the raw device is almost always faster.
returns the following values:
Either no errors were detected or all errors were corrected.
A syntax error or other operational error occurred when invoked
with the option.
Root file system errors were corrected.
The system must be rebooted.
Some uncorrected errors exist on one or more of the file systems
there was a syntax error, or some other operational error
A signal was caught during processing.
The open of the device file failed.
The file system is unmounted and needs additional checking.
The file system is mounted.
The file system is damaged.
should not be run on mounted file systems or on the root device. If
you do run on mounted file systems, be sure the system is in single-
user state (see shutdown(1M)).
The special case of the option, will disable all internal caches, which
will reduce memory usage but may impact performance.
The option, from prior releases, has been replaced by the option.
was developed by HP, AT&T, the University of California, Berkeley.
Default list of file systems to check.
List of locations of the superblocks for file systems. The
command appends entries to this file.
SEE ALSOdumpfs(1M), fsck(1M), fsck_vxfs(1M), fsclean(1M), mkfs(1M), newfs(1M),
shutdown(1M), fstab(4), acl(5), fs_wrapper(5), disk(7).