Commit | Line | Data |
---|---|---|
922de9ec | 1 | .\" Copyright (c) 1980, 1989 Regents of the University of California. |
2d5205c6 KM |
2 | .\" All rights reserved. The Berkeley software License Agreement |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
cd156a5e | 5 | .\" @(#)fsck.8 6.8 (Berkeley) %G% |
2d5205c6 | 6 | .\" |
96cc60b3 | 7 | .TH FSCK 8 "" |
2d5205c6 KM |
8 | .UC 4 |
9 | .de us | |
10 | \\$1\l'|0\(ul' | |
11 | .. | |
12 | .SH NAME | |
13 | fsck \- file system consistency check and interactive repair | |
14 | .SH SYNOPSIS | |
922de9ec | 15 | .B fsck |
2d5205c6 KM |
16 | .B \-p |
17 | [ | |
c689da7b KM |
18 | .B \-m |
19 | mode | |
2d5205c6 KM |
20 | ] |
21 | .br | |
922de9ec | 22 | .B fsck |
2d5205c6 | 23 | [ |
0e46db50 KM |
24 | .B \-b |
25 | block# | |
26 | ] [ | |
6209594a KM |
27 | .B \-c |
28 | ] [ | |
2d5205c6 KM |
29 | .B \-y |
30 | ] [ | |
31 | .B \-n | |
32 | ] [ | |
c689da7b KM |
33 | .B \-m |
34 | mode | |
35 | ] [ | |
2d5205c6 KM |
36 | filesystem |
37 | ] ... | |
38 | .SH DESCRIPTION | |
39 | The first form of | |
40 | .I fsck | |
41 | preens a standard set of filesystems or the specified file systems. | |
42 | It is normally used in the script | |
43 | .B /etc/rc | |
44 | during automatic reboot. | |
cd156a5e | 45 | Here |
2d5205c6 KM |
46 | .I fsck |
47 | reads the table | |
48 | .B /etc/fstab | |
49 | to determine which file systems to check. | |
922de9ec | 50 | Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro'' |
c27eea89 | 51 | and that have non-zero pass number are checked. |
5eeaeb24 MK |
52 | Filesystems with pass number 1 (normally just the root filesystem) |
53 | are checked one at a time. | |
54 | When pass 1 completes, all remaining filesystems are checked, | |
55 | running one process per disk drive. | |
56 | The disk drive containing each filesystem is inferred from the longest prefix | |
57 | of the device name that ends in a digit; the remaining characters are assumed | |
58 | to be the partition designator. | |
2d5205c6 KM |
59 | .PP |
60 | The system takes care that only a restricted class of innocuous | |
61 | inconsistencies can happen unless hardware or software failures intervene. | |
62 | These are limited to the following: | |
63 | .IP | |
64 | Unreferenced inodes | |
65 | .ns | |
66 | .IP | |
67 | Link counts in inodes too large | |
68 | .ns | |
69 | .IP | |
6209594a | 70 | Missing blocks in the free map |
2d5205c6 KM |
71 | .ns |
72 | .IP | |
6209594a | 73 | Blocks in the free map also in files |
2d5205c6 KM |
74 | .ns |
75 | .IP | |
76 | Counts in the super-block wrong | |
77 | .PP | |
c27eea89 | 78 | These are the only inconsistencies that |
2d5205c6 KM |
79 | .I fsck |
80 | with the | |
81 | .B \-p | |
82 | option will correct; if it encounters other inconsistencies, it exits | |
83 | with an abnormal return status and an automatic reboot will then fail. | |
84 | For each corrected inconsistency one or more lines will be printed | |
85 | identifying the file system on which the correction will take place, | |
86 | and the nature of the correction. After successfully correcting a file | |
87 | system, | |
88 | .I fsck | |
c27eea89 KM |
89 | will print the number of files on that file system, |
90 | the number of used and free blocks, | |
91 | and the percentage of fragmentation. | |
92 | .PP | |
93 | If sent a QUIT signal, | |
94 | .I fsck | |
95 | will finish the file system checks, then exit with an abnormal | |
5eeaeb24 MK |
96 | return status that causes an automatic reboot to fail. |
97 | This is useful when to finish the file system checks during an automatic reboot, | |
98 | but do not want the machine to come up multiuser after the checks complete. | |
2d5205c6 KM |
99 | .PP |
100 | Without the | |
101 | .B \-p | |
102 | option, | |
103 | .I fsck | |
104 | audits and interactively repairs inconsistent conditions for file systems. | |
105 | If the file system is inconsistent the operator is prompted for concurrence | |
106 | before each correction is attempted. | |
c27eea89 KM |
107 | It should be noted that some of the corrective actions which are not |
108 | correctable under the | |
2d5205c6 | 109 | .B \-p |
c27eea89 | 110 | option will result in some loss of data. |
2d5205c6 KM |
111 | The amount and severity of data lost may be determined from the diagnostic |
112 | output. | |
113 | The default action for each consistency correction | |
114 | is to wait for the operator to respond \fByes\fP or \fBno\fP. | |
c27eea89 | 115 | If the operator does not have write permission on the file system |
2d5205c6 KM |
116 | .I fsck |
117 | will default to a | |
118 | .BR "\-n " action. | |
119 | .PP | |
120 | .I Fsck | |
121 | has more consistency checks than | |
122 | its predecessors | |
123 | .IR "check, dcheck, fcheck, " "and" " icheck" | |
124 | combined. | |
125 | .PP | |
126 | The following flags are interpreted by | |
127 | .I fsck. | |
128 | .TP 6 | |
0e46db50 KM |
129 | .B \-b |
130 | Use the block specified immediately after the flag as | |
6209594a | 131 | the super block for the file system. Block 32 is usually |
0e46db50 KM |
132 | an alternate super block. |
133 | .TP 6 | |
5eeaeb24 MK |
134 | .B \-l |
135 | Limit the number of parallel checks to the number specified in the following | |
136 | argument. | |
137 | By default, the limit is the number of disks, running one process per disk. | |
138 | If a smaller limit is given, the disks are checked round-robin, one filesystem | |
139 | at a time. | |
140 | .TP 6 | |
c689da7b KM |
141 | .B \-m |
142 | Use the mode specified in octal immediately after the flag as the | |
143 | permission bits to use when creating the lost+found directory | |
144 | rather than the default 1777. | |
145 | In particular, systems that do not wish to have lost files accessible | |
146 | by all users on the system should use a more restrictive | |
147 | set of permissions such as 700. | |
148 | .TP 6 | |
2d5205c6 KM |
149 | .B \-y |
150 | Assume a yes response to all questions asked by | |
922de9ec | 151 | .IR fsck ; |
2d5205c6 KM |
152 | this should be used with great caution as this is a free license |
153 | to continue after essentially unlimited trouble has been encountered. | |
154 | .TP 6 | |
155 | .B \-n | |
156 | Assume a no response to all questions asked by | |
922de9ec MK |
157 | .I fsck |
158 | except for ``CONTINUE?'', which is assumed to be affirmative; | |
2d5205c6 | 159 | do not open the file system for writing. |
6209594a KM |
160 | .TP 6 |
161 | .B \-c | |
162 | If the file system is in the old (static table) format, | |
163 | convert it to the new (dynamic table) format. | |
164 | If the file system is in the new format, | |
165 | convert it to the old format provided the old format | |
166 | can support the filesystem configuration. | |
167 | In interactive mode, | |
168 | .I fsck | |
169 | will list the direction the conversion is to be made | |
170 | and ask whether the conversion should be done. | |
171 | If a negative answer is given, | |
172 | no further operations are done on the filesystem. | |
173 | In preen mode, | |
174 | the direction of the conversion is listed and done if | |
175 | possible without user interaction. | |
176 | Conversion in preen mode is best used when all the file systems | |
177 | are being converted at once. | |
178 | The format of a file system can be determined from the | |
179 | first line of output from | |
180 | .IR dumpfs (8). | |
2d5205c6 KM |
181 | .PP |
182 | If no filesystems are given to | |
183 | .I fsck | |
184 | then a default list of file systems is read from | |
185 | the file | |
186 | .BR /etc/fstab . | |
187 | .PP | |
188 | .ne 10 | |
189 | Inconsistencies checked are as follows: | |
190 | .TP 6 | |
191 | 1. | |
6209594a | 192 | Blocks claimed by more than one inode or the free map. |
2d5205c6 KM |
193 | .br |
194 | .br | |
195 | .ns | |
196 | .TP 6 | |
197 | 2. | |
6209594a | 198 | Blocks claimed by an inode outside the range of the file system. |
2d5205c6 KM |
199 | .br |
200 | .br | |
201 | .ns | |
202 | .TP 6 | |
203 | 3. | |
204 | Incorrect link counts. | |
205 | .br | |
206 | .br | |
207 | .ns | |
208 | .TP 6 | |
209 | 4. | |
210 | Size checks: | |
211 | .br | |
212 | .ns | |
213 | .IP "" 12 | |
0e46db50 | 214 | Directory size not of proper format. |
2d5205c6 | 215 | .br |
6209594a KM |
216 | Partially truncated file. |
217 | .br | |
2d5205c6 KM |
218 | .br |
219 | .ns | |
220 | .TP 6 | |
221 | 5. | |
222 | Bad inode format. | |
223 | .br | |
224 | .br | |
225 | .ns | |
226 | .TP 6 | |
227 | 6. | |
228 | Blocks not accounted for anywhere. | |
229 | .br | |
230 | .br | |
231 | .ns | |
232 | .TP 6 | |
233 | 7. | |
234 | Directory checks: | |
235 | .br | |
236 | .br | |
237 | .ns | |
238 | .IP "" 12 | |
239 | File pointing to unallocated inode. | |
240 | .br | |
241 | Inode number out of range. | |
242 | .br | |
cd156a5e KM |
243 | Dot or dot-dot not the first two entries of a directory |
244 | or having the wrong inode number. | |
245 | .br | |
2d5205c6 KM |
246 | .br |
247 | .ns | |
248 | .TP 6 | |
249 | 8. | |
250 | Super Block checks: | |
251 | .br | |
252 | .br | |
253 | .ns | |
254 | .IP "" 12 | |
2d5205c6 KM |
255 | More blocks for inodes than there are in the file system. |
256 | .br | |
257 | .br | |
258 | .ns | |
259 | .TP 6 | |
260 | 9. | |
6209594a | 261 | Bad free block map format. |
2d5205c6 KM |
262 | .br |
263 | .br | |
264 | .ns | |
265 | .TP 6 | |
266 | 10. | |
267 | Total free block and/or free inode count incorrect. | |
268 | .PP | |
269 | Orphaned files and directories (allocated but unreferenced) are, | |
270 | with the operator's concurrence, reconnected by | |
271 | placing them in the | |
272 | .B lost+found | |
273 | directory. | |
c27eea89 KM |
274 | The name assigned is the inode number. |
275 | If the | |
276 | .I lost+found | |
277 | directory does not exist, it is created. | |
278 | If there is insufficient space its size is increased. | |
2d5205c6 | 279 | .PP |
cd156a5e KM |
280 | Because of inconsistencies between the block device and the buffer cache, |
281 | the raw device should always be used. | |
2d5205c6 KM |
282 | .SH FILES |
283 | .br | |
284 | .ns | |
285 | .TP 21 | |
286 | /etc/fstab | |
287 | contains default list of file systems to check. | |
288 | .SH DIAGNOSTICS | |
289 | The diagnostics produced by | |
290 | .I fsck | |
c27eea89 KM |
291 | are fully enumerated and explained in Appendix A of |
292 | ``Fsck \- The UNIX File System Check Program'' (SMM:5). | |
2d5205c6 | 293 | .SH "SEE ALSO" |
0e46db50 KM |
294 | fstab(5), |
295 | fs(5), | |
8ad6dcc6 | 296 | fsdb(8), |
0e46db50 KM |
297 | newfs(8), |
298 | mkfs(8), | |
0e46db50 | 299 | reboot(8) |