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