1FSCK(8) System Manager's Manual FSCK(8)
2
3
4
6 fsck - file system consistency check and interactive repair
7
9 fsck -p[ # ] [ filesystem ... ]
10 fsck [ -y ] [ -n ] [ -sX ] [ -SX ] [ -t filename ] [ filesystem ] ...
11
13 The first form of fsck preens a standard set of file systems or the
14 specified file systems. It is normally used in the script /etc/rc dur‐
15 ing automatic reboot. In this case fsck reads the table /etc/fstab to
16 determine which file systems to check. It uses the information there
17 to inspect groups of disks in parallel taking maximum advantage of i/o
18 overlap to check the file systems as quickly as possible. Normally,
19 the root file system will be checked on pass 1, other ``root'' (``a''
20 partition) file systems on pass 2, other small file systems on separate
21 passes (e.g. the ``d'' file systems on pass 3 and the ``e'' file sys‐
22 tems on pass 4), and finally the large user file systems on the last
23 pass, e.g. pass 5. Only one file system from each disk should be
24 checked in each pass. A pass number of 0 in fstab causes a disk to not
25 be checked; similarly partitions which are not shown as to be mounted
26 ``rw'' or ``ro'' are not checked. A number or range of numbers may be
27 given after the -p to start or end the check at a specified pass num‐
28 ber. A single number specifies the starting pass (e.g. -p2 or -p2-); a
29 range specifies the starting and endig passes (-p2-4). A missing start
30 means to start with pass 1 (-p-2). These can be used to stop fsck to
31 mount a temporary file system before continuing the check on larger
32 file systems requiring scratch files.
33
34 The system normally takes care that only a restricted class of innocu‐
35 ous inconsistencies can happen unless hardware or software failures
36 intervene. These are limited to the following:
37
38 Unreferenced inodes
39
40 Link counts in inodes too large
41
42 Missing blocks in the free list
43
44 Blocks in the free list also in files
45
46 Counts in the superblock wrong
47
48 Allocated inodes in the free inode list
49
50 These are the only inconsistencies which fsck with the -p option will
51 correct; if it encounters other inconsistencies, it exits with an
52 abnormal return status and an automatic reboot will then fail. For
53 each corrected inconsistency one or more lines will be printed identi‐
54 fying the file system on which the correction will take place, and the
55 nature of the correction. After successfully correcting a file system,
56 fsck will print the number of files on that file system and the number
57 of used and free blocks. Warning: kernel changes are required to limit
58 the types of inconsistencies, and fsck -p makes assumptions about the
59 kernel's actions in repairing these. Vmunix, PDP-11 2.9BSD with the
60 UCB_FSFIX option and PDP-11 2.10BSD Unix kernels have the appropriate
61 modifications; the -p option should not be used on other systems.
62
63 Without the -p option, fsck audits and interactively repairs inconsis‐
64 tent conditions for file systems. If the file system is inconsistent
65 the operator is prompted for concurrence before each correction is
66 attempted. It should be noted that a number of the corrective actions
67 which are not fixable under the -p option will result in some loss of
68 data. The amount and severity of data lost may be determined from the
69 diagnostic output. The default action for each consistency correction
70 is to wait for the operator to respond yes or no. If the operator does
71 not have write permission fsck will default to a -n action.
72
73 Fsck has more consistency checks than its predecessors check, dcheck,
74 fcheck, and icheck combined.
75
76 The following flags are interpreted by fsck.
77
78 -y Assume a yes response to all questions asked by fsck; this should
79 be used with great caution as this is a free license to continue
80 after essentially unlimited trouble has been encountered.
81
82 -n Assume a no response to all questions asked by fsck; do not open
83 the file system for writing.
84
85 -sX Ignore the actual free list and (unconditionally) reconstruct a
86 new one by rewriting the superblock of the file system. The file
87 system should be unmounted while this is done; if this is not
88 possible, care should be taken that the system is quiescent and
89 that it is rebooted immediately afterwards. This precaution is
90 necessary so that the old, bad, in-core copy of the superblock
91 will not continue to be used, or written on the file system.
92
93 The -sX option allows for creating an optimal free list organiza‐
94 tion. The following forms of X are supported for the following
95 devices:
96
97 -s3 (RP03)
98 -s4 (RP04, RP05, RP06)
99 -sBlocks-per-cylinder:Blocks-to-skip (for anything else)
100
101 If X is not given, the values used when the file system was cre‐
102 ated are used. If these values were not specified, then the
103 value 400:9 is used.
104
105 -SX Conditionally reconstruct the free list. This option is like -sX
106 above except that the free list is rebuilt only if there were no
107 discrepancies discovered in the file system. Using -S will force
108 a no response to all questions asked by fsck. This option is
109 useful for forcing free list reorganization on uncontaminated
110 file systems.
111
112 -t If fsck cannot obtain enough memory to keep its tables, it uses a
113 scratch file. If the -t option is specified, the file named in
114 the next argument is used as the scratch file, if needed. Without
115 the -t flag, fsck will prompt the operator for the name of the
116 scratch file. The file chosen should not be on the file system
117 being checked, and if it is not a special file or did not already
118 exist, it is removed when fsck completes.
119
120 If no file systems are given to fsck then a default list of file sys‐
121 tems is read from the file /etc/fstab.
122
123 Inconsistencies checked are as follows:
124
125 1. Blocks claimed by more than one inode or the free list.
126 2. Blocks claimed by an inode or the free list outside the range of
127 the file system.
128 3. Incorrect link counts.
129 4. Size checks:
130 Directory size not 16-byte aligned.
131 5. Bad inode format.
132 6. Blocks not accounted for anywhere.
133 7. Directory checks:
134 File pointing to unallocated inode.
135 Inode number out of range.
136 8. Super Block checks:
137 More than 65536 inodes.
138 More blocks for inodes than there are in the file system.
139 9. Bad free block list format.
140 10. Total free block and/or free inode count incorrect.
141 11. Allocated inodes on the free inode list in the superblock.
142
143 Orphaned files and directories (allocated but unreferenced) are, with
144 the operator's concurrence, reconnected by placing them in the
145 lost+found directory. The name assigned is the inode number. The only
146 restriction is that the directory lost+found must preexist in the root
147 of the file system being checked and must have empty slots in which
148 entries can be made. This can be accomplished manually by making
149 lost+found, copying a number of files to the directory, and then remov‐
150 ing them (before fsck is executed). Mkfs(8) will automatically create
151 a lost+found directory.
152
153 Checking the raw device is almost always faster. The root device
154 should not be checked using the raw device, however, since it cannot be
155 unmounted.
156
158 /etc/fstab default list of file systems to check
159
161 The diagnostics produced by fsck are intended to be self-explanatory.
162 The exit codes with the -p option are 0 (no problems that weren't
163 fixed), 4 (root file system was modified), 8 (problems that couldn't be
164 fixed) and 12 (fsck was interrupted).
165
167 filsys(5), fstab(5), crash(8), mkfs(8), mklost+found(8), reboot(8)
168 T. J. Kowalski, FSCK - The UNIX File System Check Program
169
171 Inode numbers for . and .. in each directory should be checked for
172 validity.
173
174
175
1763rd Berkeley Distribution FSCK(8)