fsck
filesystem consistency check and repair
fsck [-p
][-f
] [-m
mode]
fsck
[-b
superBlockNumber ]
[-c
level]
[-l
maxparallel]
[-q
]
[-y
|
-n
]
[-m
mode]
See Disk Utility for running on individual volumes.
During boot, /etc/rc
( 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 -p
(preen)
- 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
Other inconsistencies, cause an exit with abnormal return status and an automatic boot fails.
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 QUIT
signal, fsck
completes the checks then exits
with an abnormal return status which causes boot to fail, prevents starting multiuser mode.
Without -p, fsck
audits and interactively repairs inconsistent
conditions. The user is prompted for permission before each correction is attempted (unless -y
or -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.
-p preen
| -f Force ie include clean filesystems when preening.
| -m rwxrwxrwx Permissions for lost+found directory if created rather than 1777 which is a security risk, 700 is suggested.
|
| ‑b alt‑super‑block Block 32 is usually an alternate super block.
| -l p 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.
| -q quickly determine if filesystem was unmounted cleanly.
| -y Supply a yes response to all questions ; this should be used with great caution
| -n Supply a no response to all questions except
for CONTINUE? , which is assumed to be affirmative;
Do not open the filesystem for writing.
| -c level Convert the filesystem to a higher level.
- 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.
In interactive mode, fsck 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
filesystem.
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).
| | | | | | | | | |
If no filesystems are specified filesystems as per /etc/fstab
.
Inconsistencies checked are :
- 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:
- More blocks for inodes than there are in the filesystem.
- Bad free block map format.
- Total free block and/or free inode count incorrect.
Orphaned files and directories (allocated but unreferenced) are, with the
user's permission, 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.
The raw device should always be used.
FILES
/etc/fstab
contains default list of filesystems to check.
see fs(5), fstab(5), newfs(8), reboot(8)
e2fsck