filesystem consistency check and repair
-b superBlockNumber ]
See Disk Utility for running on individual volumes.
launchd on Mac OS ) specifies filesystems to be checked.
In addition the filesystems in
/etc/fstab which are not marked
clean are checked.
(Filesystems are marked
clean when they are unmounted (as in shutdown),
have been mounted read-only, or when fsck runs on them successfully).
There is a unique
fsck for each type of file system,( example: fsck_hfs )
and the actions and options vary.
The only inconsistencies corrected with
Other inconsistencies, cause an exit with abnormal return status and an automatic boot fails.
- Unreferenced inodes
- Link counts in inodes too large
- Missing blocks in the free map
- Blocks in the free map and allocated to files
- incorrect super-block counts
During processing, the filesystem, the corrective action, and the nature of the correction are displayed.
After successfully correcting a filesystem,
fsck displays the
number of files on that filesystem, the number of used and free blocks, and the percentage of fragmentation.
If sent a
fsck completes the checks then exits
with an abnormal return status which causes boot to fail, prevents starting multiuser mode.
-p, fsck audits and interactively repairs inconsistent
conditions. The user is prompted for permission before each correction is attempted (unless
-n is specified).
Some of the corrective actions , not correctable under
-p, will result in some loss of data.
The amount and severity of data lost is displayed .
If the user does not have write permission on the filesystem no action is taken.
If no filesystems are specified filesystems as per
| Force ie include |
clean filesystems when preening.
| Permissions for |
lost+found directory if created rather than 1777 which is a security risk, 700 is suggested.
| Block 32 is usually an alternate super block.
| Limit the number of parallel checks.
By default, the limit is the number of disks, one process per disk. If a smaller
limit is given, the disks are checked round-robin, one filesystem at a time.
| quickly determine if |
filesystem was unmounted cleanly.
| Supply a yes response to all questions ; this should be used with great caution
| Supply a no response to all questions except
CONTINUE?, which is assumed to be affirmative;
Do not open the filesystem for writing.
| Convert the filesystem to a higher level.
In interactive mode, fsck will list the conversion to be made
and ask whether the conversion should be done.
- 0 old (static table) format.
- 1 new (dynamic table) format.
- 2 supports 32-bit uid's and gid's, short symbolic links are stored in the inode,
and directories have an added field showing the file type.
- 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.
If a negative answer is given, no further operations are done on the
In preen mode, the conversion is listed and done
if possible without user interaction. Conversion in preen
mode is best used when all the filesystems are being converted at once.
The format of a filesystem can be determined
from the first line of output from dumpfs(8).
Inconsistencies checked are :
The raw device should always be used.
- Blocks claimed by more than one inode or the free map.
- Blocks claimed by an inode outside the range of the filesystem.
- 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:
Orphaned files and directories (allocated but unreferenced) are, with the
user's permission, reconnected by placing them in the
- More blocks for inodes than there are in the filesystem.
- Bad free block map format.
- Total free block and/or free inode count incorrect.
directory. The name assigned is the inode number. If the
directory does not exist, it is created. If there is insufficient space
its size is increased.
/etc/fstab contains default list of filesystems to check.
Appendix A of Fsck - The UNIX File System Check Program.
Fsck has more consistency checks than its predecessors check, dcheck, fcheck, and icheck combined.
fs(5), fstab(5), newfs(8), reboot(8)
FSCK(8) BSD System Manager's Manual
4th Berkeley Distribution May 9, 1995