]>
Commit | Line | Data |
---|---|---|
607c2a72 KZ |
1 | .\" -*- nroff -*- |
2 | .\" Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved. | |
3 | .\" This file may be copied under the terms of the GNU Public License. | |
c45b8d6a | 4 | .\" |
232dc924 | 5 | .TH FSCK 8 "February 2009" "util-linux" "System Administration" |
607c2a72 | 6 | .SH NAME |
92623f46 | 7 | fsck \- check and repair a Linux filesystem |
607c2a72 KZ |
8 | .SH SYNOPSIS |
9 | .B fsck | |
dd0bd943 | 10 | .RB [ \-lsAVRTMNP ] |
c45b8d6a PB |
11 | .RB [ \-C |
12 | .RI [ fd ]] | |
13 | .RB [ \-t | |
14 | .IR fstype ] | |
15 | .RI [ filesys ...] | |
16 | .RB [ \-\- ] | |
17 | .RI [ fs-specific-options ] | |
607c2a72 KZ |
18 | .SH DESCRIPTION |
19 | .B fsck | |
92623f46 | 20 | is used to check and optionally repair one or more Linux filesystems. |
607c2a72 KZ |
21 | .I filesys |
22 | can be a device name (e.g. | |
23 | .IR /dev/hdc1 ", " /dev/sdb2 ), | |
24 | a mount point (e.g. | |
25 | .IR / ", " /usr ", " /home ), | |
26 | or an ext2 label or UUID specifier (e.g. | |
c45b8d6a PB |
27 | UUID=8868abf6-88c5-4a83-98b8-bfc24057f7bd or LABEL=root). |
28 | Normally, the | |
29 | .B fsck | |
30 | program will try to handle filesystems on different physical disk drives | |
92623f46 | 31 | in parallel to reduce the total amount of time needed to check all of them. |
607c2a72 | 32 | .PP |
c45b8d6a PB |
33 | If no filesystems are specified on the command line, and the |
34 | .B \-A | |
35 | option is not specified, | |
607c2a72 KZ |
36 | .B fsck |
37 | will default to checking filesystems in | |
38 | .B /etc/fstab | |
c45b8d6a | 39 | serially. This is equivalent to the |
607c2a72 KZ |
40 | .B \-As |
41 | options. | |
42 | .PP | |
43 | The exit code returned by | |
44 | .B fsck | |
45 | is the sum of the following conditions: | |
fdbc2509 SK |
46 | .PP |
47 | .RS | |
48 | .PD 0 | |
49 | .TP | |
50 | .B 0 | |
51 | No errors | |
52 | .TP | |
53 | .B 1 | |
54 | Filesystem errors corrected | |
55 | .TP | |
56 | .B 2 | |
57 | System should be rebooted | |
58 | .TP | |
59 | .B 4 | |
60 | Filesystem errors left uncorrected | |
61 | .TP | |
62 | .B 8 | |
63 | Operational error | |
64 | .TP | |
65 | .B 16 | |
66 | Usage or syntax error | |
67 | .TP | |
68 | .B 32 | |
69 | Fsck canceled by user request | |
70 | .TP | |
71 | .B 128 | |
72 | Shared-library error | |
73 | .PD | |
74 | .RE | |
75 | .PP | |
92623f46 | 76 | The exit code returned when multiple filesystems are checked |
607c2a72 | 77 | is the bit-wise OR of the exit codes for each |
92623f46 | 78 | filesystem that is checked. |
607c2a72 KZ |
79 | .PP |
80 | In actuality, | |
81 | .B fsck | |
92623f46 BS |
82 | is simply a front-end for the various filesystem checkers |
83 | (\fBfsck\fR.\fIfstype\fR) available under Linux. The | |
84 | filesystem-specific checker is searched for in | |
607c2a72 KZ |
85 | .I /sbin |
86 | first, then in | |
87 | .I /etc/fs | |
88 | and | |
89 | .IR /etc , | |
90 | and finally in the directories listed in the PATH environment | |
92623f46 | 91 | variable. Please see the filesystem-specific checker manual pages for |
607c2a72 KZ |
92 | further details. |
93 | .SH OPTIONS | |
94 | .TP | |
dd0bd943 | 95 | .B \-l |
92623f46 | 96 | Lock the whole-disk device by an exclusive |
dd0bd943 | 97 | .BR flock (2). |
92623f46 BS |
98 | This option can be used with one device only (this means that \fB-A\fR and |
99 | \fB-l\fR are mutually exclusive). This option is recommended when more | |
dd0bd943 | 100 | .B fsck (8) |
92623f46 BS |
101 | instances are executed in the same time. The option is ignored when used for |
102 | multiple devices or for non-rotating disks. \fBfsck\fR does not lock underlying | |
103 | devices when executed to check stacked devices (e.g. MD or DM) -- this feature is | |
dd0bd943 KZ |
104 | not implemented yet. |
105 | .TP | |
607c2a72 | 106 | .B \-s |
c45b8d6a PB |
107 | Serialize |
108 | .B fsck | |
607c2a72 KZ |
109 | operations. This is a good idea if you are checking multiple |
110 | filesystems and the checkers are in an interactive mode. (Note: | |
111 | .BR e2fsck (8) | |
c45b8d6a | 112 | runs in an interactive mode by default. To make |
607c2a72 KZ |
113 | .BR e2fsck (8) |
114 | run in a non-interactive mode, you must either specify the | |
115 | .B \-p | |
116 | or | |
117 | .B \-a | |
c45b8d6a | 118 | option, if you wish for errors to be corrected automatically, or the |
607c2a72 KZ |
119 | .B \-n |
120 | option if you do not.) | |
121 | .TP | |
122 | .BI \-t " fslist" | |
92623f46 | 123 | Specifies the type(s) of filesystem to be checked. When the |
c45b8d6a PB |
124 | .B \-A |
125 | flag is specified, only filesystems that match | |
607c2a72 KZ |
126 | .I fslist |
127 | are checked. The | |
128 | .I fslist | |
129 | parameter is a comma-separated list of filesystems and options | |
130 | specifiers. All of the filesystems in this comma-separated list may be | |
c45b8d6a | 131 | prefixed by a negation operator |
607c2a72 | 132 | .RB ' no ' |
c45b8d6a | 133 | or |
607c2a72 KZ |
134 | .RB ' ! ', |
135 | which requests that only those filesystems not listed in | |
136 | .I fslist | |
92623f46 | 137 | will be checked. If none of the filesystems in |
607c2a72 | 138 | .I fslist |
92623f46 | 139 | is prefixed by a negation operator, then only those listed filesystems |
607c2a72 KZ |
140 | will be checked. |
141 | .sp | |
142 | Options specifiers may be included in the comma-separated | |
143 | .IR fslist . | |
c45b8d6a | 144 | They must have the format |
607c2a72 KZ |
145 | .BI opts= fs-option\fR. |
146 | If an options specifier is present, then only filesystems which contain | |
147 | .I fs-option | |
c45b8d6a | 148 | in their mount options field of |
607c2a72 KZ |
149 | .B /etc/fstab |
150 | will be checked. If the options specifier is prefixed by a negation | |
c45b8d6a | 151 | operator, then only |
607c2a72 KZ |
152 | those filesystems that do not have |
153 | .I fs-option | |
154 | in their mount options field of | |
c45b8d6a | 155 | .B /etc/fstab |
607c2a72 KZ |
156 | will be checked. |
157 | .sp | |
158 | For example, if | |
159 | .B opts=ro | |
160 | appears in | |
161 | .IR fslist , | |
162 | then only filesystems listed in | |
c45b8d6a | 163 | .B /etc/fstab |
607c2a72 KZ |
164 | with the |
165 | .B ro | |
166 | option will be checked. | |
167 | .sp | |
168 | For compatibility with Mandrake distributions whose boot scripts | |
169 | depend upon an unauthorized UI change to the | |
170 | .B fsck | |
171 | program, if a filesystem type of | |
172 | .B loop | |
173 | is found in | |
174 | .IR fslist , | |
175 | it is treated as if | |
176 | .B opts=loop | |
177 | were specified as an argument to the | |
178 | .B \-t | |
179 | option. | |
180 | .sp | |
181 | Normally, the filesystem type is deduced by searching for | |
182 | .I filesys | |
c45b8d6a PB |
183 | in the |
184 | .I /etc/fstab | |
607c2a72 | 185 | file and using the corresponding entry. |
c45b8d6a PB |
186 | If the type can not be deduced, and there is only a single filesystem |
187 | given as an argument to the | |
188 | .B \-t | |
189 | option, | |
607c2a72 KZ |
190 | .B fsck |
191 | will use the specified filesystem type. If this type is not | |
92623f46 | 192 | available, then the default filesystem type (currently ext2) is used. |
607c2a72 KZ |
193 | .TP |
194 | .B \-A | |
195 | Walk through the | |
196 | .I /etc/fstab | |
92623f46 | 197 | file and try to check all filesystems in one run. This option is |
607c2a72 KZ |
198 | typically used from the |
199 | .I /etc/rc | |
200 | system initialization file, instead of multiple commands for checking | |
92623f46 | 201 | a single filesystem. |
607c2a72 KZ |
202 | .sp |
203 | The root filesystem will be checked first unless the | |
204 | .B \-P | |
c45b8d6a PB |
205 | option is specified (see below). After that, |
206 | filesystems will be checked in the order specified by the | |
207 | .I fs_passno | |
208 | (the sixth) field in the | |
607c2a72 | 209 | .I /etc/fstab |
c45b8d6a PB |
210 | file. |
211 | Filesystems with a | |
607c2a72 KZ |
212 | .I fs_passno |
213 | value of 0 are skipped and are not checked at all. Filesystems with a | |
214 | .I fs_passno | |
c45b8d6a | 215 | value of greater than zero will be checked in order, |
607c2a72 | 216 | with filesystems with the lowest |
c45b8d6a | 217 | .I fs_passno |
607c2a72 | 218 | number being checked first. |
c45b8d6a PB |
219 | If there are multiple filesystems with the same pass number, |
220 | fsck will attempt to check them in parallel, although it will avoid running | |
221 | multiple filesystem checks on the same physical disk. | |
607c2a72 | 222 | .sp |
0c0f93fc KZ |
223 | .B fsck |
224 | does not check stacked devices (RAIDs, dm-crypt, ...) in parallel with any other | |
92623f46 | 225 | device. See below for FSCK_FORCE_ALL_PARALLEL setting. The /sys filesystem is |
0c0f93fc KZ |
226 | used to detemine dependencies between devices. |
227 | .sp | |
c45b8d6a | 228 | Hence, a very common configuration in |
607c2a72 | 229 | .I /etc/fstab |
c45b8d6a | 230 | files is to set the root filesystem to have a |
607c2a72 KZ |
231 | .I fs_passno |
232 | value of 1 | |
233 | and to set all other filesystems to have a | |
234 | .I fs_passno | |
235 | value of 2. This will allow | |
236 | .B fsck | |
237 | to automatically run filesystem checkers in parallel if it is advantageous | |
238 | to do so. System administrators might choose | |
239 | not to use this configuration if they need to avoid multiple filesystem | |
240 | checks running in parallel for some reason --- for example, if the | |
241 | machine in question is short on memory so that | |
242 | excessive paging is a concern. | |
0779255c LN |
243 | .sp |
244 | .B fsck | |
245 | normally does not check whether the device actually exists before | |
92623f46 BS |
246 | calling a filesystem specific checker. Therefore non-existing |
247 | devices may cause the system to enter filesystem repair mode during | |
248 | boot if the filesystem specific checker returns a fatal error. The | |
0779255c LN |
249 | .B /etc/fstab |
250 | mount option | |
251 | .B nofail | |
252 | may be used to have | |
253 | .B fsck | |
254 | skip non-existing devices. | |
255 | .B fsck | |
92623f46 | 256 | also skips non-existing devices that have the special filesystem type |
fdbc2509 | 257 | .BR auto . |
607c2a72 KZ |
258 | .TP |
259 | .B \-C\fR [ \fI "fd" \fR ] | |
c45b8d6a | 260 | Display completion/progress bars for those filesystem checkers (currently |
607c2a72 | 261 | only for ext2 and ext3) which support them. Fsck will manage the |
c45b8d6a | 262 | filesystem checkers so that only one of them will display |
607c2a72 KZ |
263 | a progress bar at a time. GUI front-ends may specify a file descriptor |
264 | .IR fd , | |
265 | in which case the progress bar information will be sent to that file descriptor. | |
266 | .TP | |
267 | .B \-M | |
268 | Do not check mounted filesystems and return an exit code of 0 | |
269 | for mounted filesystems. | |
270 | .TP | |
271 | .B \-N | |
272 | Don't execute, just show what would be done. | |
273 | .TP | |
274 | .B \-P | |
c45b8d6a | 275 | When the |
607c2a72 KZ |
276 | .B \-A |
277 | flag is set, check the root filesystem in parallel with the other filesystems. | |
278 | This is not the safest thing in the world to do, | |
c45b8d6a PB |
279 | since if the root filesystem is in doubt things like the |
280 | .BR e2fsck (8) | |
607c2a72 KZ |
281 | executable might be corrupted! This option is mainly provided |
282 | for those sysadmins who don't want to repartition the root | |
283 | filesystem to be small and compact (which is really the right solution). | |
284 | .TP | |
285 | .B \-R | |
92623f46 | 286 | When checking all filesystems with the |
607c2a72 | 287 | .B \-A |
92623f46 BS |
288 | flag, skip the root filesystem. (This is useful in case the root |
289 | filesystem has already been mounted read-write.) | |
607c2a72 KZ |
290 | .TP |
291 | .B \-T | |
292 | Don't show the title on startup. | |
293 | .TP | |
294 | .B \-V | |
92623f46 | 295 | Produce verbose output, including all filesystem-specific commands |
607c2a72 KZ |
296 | that are executed. |
297 | .TP | |
298 | .B fs-specific-options | |
c45b8d6a PB |
299 | Options which are not understood by |
300 | .B fsck | |
607c2a72 KZ |
301 | are passed to the filesystem-specific checker. These arguments |
302 | .B must | |
303 | not take arguments, as there is no | |
c45b8d6a | 304 | way for |
607c2a72 | 305 | .B fsck |
92623f46 | 306 | to be able to properly guess which options take arguments and which |
607c2a72 KZ |
307 | don't. |
308 | .IP | |
309 | Options and arguments which follow the | |
310 | .B \-\- | |
92623f46 BS |
311 | are treated as filesystem-specific options to be passed to the |
312 | filesystem-specific checker. | |
607c2a72 KZ |
313 | .IP |
314 | Please note that fsck is not | |
315 | designed to pass arbitrarily complicated options to filesystem-specific | |
316 | checkers. If you're doing something complicated, please just | |
c45b8d6a | 317 | execute the filesystem-specific checker directly. If you pass |
607c2a72 | 318 | .B fsck |
92623f46 | 319 | some horribly complicated options and arguments, and it doesn't do |
c45b8d6a | 320 | what you expect, |
607c2a72 KZ |
321 | .B don't bother reporting it as a bug. |
322 | You're almost certainly doing something that you shouldn't be doing | |
c45b8d6a | 323 | with |
607c2a72 KZ |
324 | .BR fsck. |
325 | .PP | |
326 | Options to different filesystem-specific fsck's are not standardized. | |
327 | If in doubt, please consult the man pages of the filesystem-specific | |
328 | checker. Although not guaranteed, the following options are supported | |
92623f46 | 329 | by most filesystem checkers: |
607c2a72 KZ |
330 | .TP |
331 | .B \-a | |
92623f46 | 332 | Automatically repair the filesystem without any questions (use |
c45b8d6a | 333 | this option with caution). Note that |
607c2a72 | 334 | .BR e2fsck (8) |
c45b8d6a | 335 | supports |
607c2a72 | 336 | .B \-a |
92623f46 | 337 | for backward compatibility only. This option is mapped to |
607c2a72 KZ |
338 | .BR e2fsck 's |
339 | .B \-p | |
c45b8d6a PB |
340 | option which is safe to use, unlike the |
341 | .B \-a | |
92623f46 | 342 | option that some filesystem checkers support. |
607c2a72 KZ |
343 | .TP |
344 | .B \-n | |
c45b8d6a | 345 | For some filesystem-specific checkers, the |
607c2a72 | 346 | .B \-n |
c45b8d6a | 347 | option will cause the fs-specific fsck to avoid attempting to repair any |
607c2a72 | 348 | problems, but simply report such problems to stdout. This is however |
c45b8d6a | 349 | not true for all filesystem-specific checkers. In particular, |
607c2a72 KZ |
350 | .BR fsck.reiserfs (8) |
351 | will not report any corruption if given this option. | |
352 | .BR fsck.minix (8) | |
c45b8d6a PB |
353 | does not support the |
354 | .B \-n | |
607c2a72 KZ |
355 | option at all. |
356 | .TP | |
357 | .B \-r | |
358 | Interactively repair the filesystem (ask for confirmations). Note: It | |
359 | is generally a bad idea to use this option if multiple fsck's are being | |
c45b8d6a | 360 | run in parallel. Also note that this is |
607c2a72 | 361 | .BR e2fsck 's |
92623f46 | 362 | default behavior; it supports this option for backward compatibility |
607c2a72 KZ |
363 | reasons only. |
364 | .TP | |
365 | .B \-y | |
c45b8d6a PB |
366 | For some filesystem-specific checkers, the |
367 | .B \-y | |
607c2a72 KZ |
368 | option will cause the fs-specific fsck to always attempt to fix any |
369 | detected filesystem corruption automatically. Sometimes an expert may | |
c45b8d6a | 370 | be able to do better driving the fsck manually. Note that |
607c2a72 | 371 | .B not |
c45b8d6a | 372 | all filesystem-specific checkers implement this option. In particular |
607c2a72 KZ |
373 | .BR fsck.minix (8) |
374 | and | |
375 | .BR fsck.cramfs (8) | |
92623f46 | 376 | do not support the |
607c2a72 KZ |
377 | .B -y |
378 | option as of this writing. | |
379 | .SH AUTHOR | |
fdbc2509 SK |
380 | .UR tytso\@mit.edu |
381 | Theodore Ts'o | |
382 | .UE | |
607c2a72 | 383 | .SH AVAILABILITY |
601d12fb | 384 | The fsck command is part of the util-linux package and is available from |
fdbc2509 SK |
385 | .UR ftp://\:ftp.kernel.org\:/pub\:/linux\:/utils\:/util-linux/ |
386 | Linux Kernel Archive | |
387 | .UE . | |
607c2a72 KZ |
388 | .SH FILES |
389 | .IR /etc/fstab . | |
390 | .SH ENVIRONMENT VARIABLES | |
391 | The | |
392 | .B fsck | |
393 | program's behavior is affected by the following environment variables: | |
394 | .TP | |
395 | .B FSCK_FORCE_ALL_PARALLEL | |
c45b8d6a | 396 | If this environment variable is set, |
607c2a72 | 397 | .B fsck |
92623f46 | 398 | will attempt to check all of the specified filesystems in parallel, regardless of |
0c0f93fc KZ |
399 | whether the filesystems appear to be on the same device. (This is useful for |
400 | RAID systems or high-end storage systems such as those sold by companies such | |
92623f46 | 401 | as IBM or EMC.) Note that the fs_passno value is still used. |
607c2a72 KZ |
402 | .TP |
403 | .B FSCK_MAX_INST | |
92623f46 | 404 | This environment variable will limit the maximum number of filesystem |
607c2a72 | 405 | checkers that can be running at one time. This allows configurations |
c45b8d6a | 406 | which have a large number of disks to avoid |
607c2a72 | 407 | .B fsck |
92623f46 | 408 | starting too many filesystem checkers at once, which might overload |
607c2a72 KZ |
409 | CPU and memory resources available on the system. If this value is |
410 | zero, then an unlimited number of processes can be spawned. This is | |
411 | currently the default, but future versions of | |
412 | .B fsck | |
92623f46 | 413 | may attempt to automatically determine how many filesystem checks can |
607c2a72 KZ |
414 | be run based on gathering accounting data from the operating system. |
415 | .TP | |
416 | .B PATH | |
c45b8d6a | 417 | The |
607c2a72 | 418 | .B PATH |
92623f46 | 419 | environment variable is used to find filesystem checkers. A set of |
c45b8d6a | 420 | system directories are searched first: |
607c2a72 KZ |
421 | .BR /sbin , |
422 | .BR /sbin/fs.d , | |
92623f46 | 423 | .BR /sbin/fs , |
607c2a72 | 424 | .BR /etc/fs , |
c45b8d6a | 425 | and |
607c2a72 KZ |
426 | .BR /etc . |
427 | Then the set of directories found in the | |
428 | .B PATH | |
429 | environment are searched. | |
430 | .TP | |
431 | .B FSTAB_FILE | |
c45b8d6a PB |
432 | This environment variable allows the system administrator |
433 | to override the standard location of the | |
607c2a72 KZ |
434 | .B /etc/fstab |
435 | file. It is also useful for developers who are testing | |
436 | .BR fsck . | |
437 | .SH SEE ALSO | |
438 | .BR fstab (5), | |
439 | .BR mkfs (8), | |
440 | .BR fsck.ext2 (8) | |
441 | or | |
442 | .BR fsck.ext3 (8) | |
443 | or | |
444 | .BR e2fsck (8), | |
445 | .BR cramfsck (8), | |
446 | .BR fsck.minix (8), | |
447 | .BR fsck.msdos (8), | |
448 | .BR fsck.jfs (8), | |
449 | .BR fsck.nfs (8), | |
450 | .BR fsck.vfat (8), | |
451 | .BR fsck.xfs (8), | |
452 | .BR fsck.xiafs (8), | |
453 | .BR reiserfsck (8). |