Whamcloud - gitweb
915273d87bb7f2ac3433eb12b9ce69bda00284a7
[tools/e2fsprogs.git] / e2fsck / e2fsck.8.in
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.
4 .\" 
5 .TH E2FSCK 8 "@E2FSPROGS_MONTH@ @E2FSPROGS_YEAR@" "E2fsprogs version @E2FSPROGS_VERSION@"
6 .SH NAME
7 e2fsck \- check a Linux ext2/ext3/ext4 file system
8 .SH SYNOPSIS
9 .B e2fsck
10 [
11 .B \-pacnyrdfkvtDFV
12 ]
13 [
14 .B \-b
15 .I superblock
16 ]
17 [
18 .B \-B
19 .I blocksize
20 ]
21 [
22 .BR \-l | \-L
23 .I bad_blocks_file
24 ]
25 [
26 .B \-C
27 .I fd
28 ]
29 @JDEV@[
30 @JDEV@.B \-j
31 @JDEV@.I external-journal
32 @JDEV@]
33 [
34 .B \-E
35 .I extended_options
36 ]
37 [
38 .B \-z
39 .I undo_file
40 ]
41 .I device
42 .SH DESCRIPTION
43 .B e2fsck
44 is used to check the ext2/ext3/ext4 family of file systems.   
45 For ext3 and ext4 filesystems that use a journal, if the system has been
46 shut down uncleanly without any errors, normally, after replaying the
47 committed transactions  in the journal, the file system should be
48 marked as clean.   Hence, for filesystems that use journalling,
49 .B e2fsck
50 will normally replay the journal and exit, unless its superblock
51 indicates that further checking is required.
52 .PP
53 .I device
54 is a block device (e.g., 
55 .IR /dev/sdc1 )
56 or file containing the file system.
57 .PP
58 Note that in general it is not safe to run
59 .B e2fsck
60 on mounted filesystems.  The only exception is if the
61 .B \-n
62 option is specified, and 
63 .BR \-c , 
64 .BR \-l ,
65 or
66 .B -L
67 options are 
68 .I not
69 specified.   However, even if it is safe to do so, the results printed by
70 .B e2fsck
71 are not valid if the filesystem is mounted.   If 
72 .B e2fsck
73 asks whether or not you should check a filesystem which is mounted, 
74 the only correct answer is ``no''.  Only experts who really know what
75 they are doing should consider answering this question in any other way.
76 .PP
77 If
78 .B e2fsck
79 is run in interactive mode (meaning that none of
80 .BR \-y ,
81 .BR \-n ,
82 or
83 .BR \-p
84 are specified), the program will ask the user to fix each problem found in the
85 filesystem.  A response of 'y' will fix the error; 'n' will leave the error
86 unfixed; and 'a' will fix the problem and all subsequent problems; pressing
87 Enter will proceed with the default response, which is printed before the
88 question mark.  Pressing Control-C terminates e2fsck immediately.
89 .SH OPTIONS
90 .TP
91 .B \-a 
92 This option does the same thing as the 
93 .B \-p
94 option.  It is provided for backwards compatibility only; it is
95 suggested that people use 
96 .B \-p 
97 option whenever possible.
98 .TP
99 .BI \-b " superblock"
100 Instead of using the normal superblock, use an alternative superblock
101 specified by 
102 .IR superblock .
103 This option is normally used when the primary superblock has been
104 corrupted.  The location of the backup superblock is dependent on the
105 filesystem's blocksize.  For filesystems with 1k blocksizes, a backup
106 superblock can be found at block 8193; for filesystems with 2k
107 blocksizes, at block 16384; and for 4k blocksizes, at block 32768.  
108 .IP
109 Additional backup superblocks can be determined by using the 
110 .B mke2fs 
111 program using the 
112 .B \-n
113 option to print out where the superblocks were created.   The 
114 .B \-b 
115 option to 
116 .BR mke2fs ,
117 which specifies blocksize of the filesystem must be specified in order
118 for the superblock locations that are printed out to be accurate.
119 .IP
120 If an alternative superblock is specified and  
121 the filesystem is not opened read-only, e2fsck will make sure that the
122 primary superblock is updated appropriately upon completion of the 
123 filesystem check.
124 .TP
125 .BI \-B " blocksize"
126 Normally, 
127 .B e2fsck
128 will search for the superblock at various different
129 block sizes in an attempt to find the appropriate block size.
130 This search can be fooled in some cases.  This option forces 
131 .B e2fsck
132 to only try locating the superblock at a particular blocksize.
133 If the superblock is not found, 
134 .B e2fsck 
135 will terminate with a fatal error.
136 .TP
137 .B \-c
138 This option causes 
139 .B e2fsck 
140 to use 
141 .BR badblocks (8)
142 program to do a read-only scan of the device in order to find any bad
143 blocks.  If any bad blocks are found, they are added to the bad block
144 inode to prevent them from being allocated to a file or directory.  If
145 this option is specified twice, then the bad block scan will be done
146 using a non-destructive read-write test.
147 .TP
148 .BI \-C " fd"
149 This option causes
150 .B e2fsck
151 to write completion information to the specified file descriptor 
152 so that the progress of the filesystem 
153 check can be monitored.  This option is typically used by programs 
154 which are running
155 .BR e2fsck .
156 If the file descriptor number is negative, then absolute value of
157 the file descriptor will be used, and the progress information will be
158 suppressed initially.  It can later be enabled by sending the
159 .B e2fsck
160 process a SIGUSR1 signal.
161 If the file descriptor specified is 0, 
162 .B e2fsck
163 will print a completion bar as it goes about its business.  This requires
164 that e2fsck is running on a video console or terminal.
165 .TP
166 .B \-d
167 Print debugging output (useless unless you are debugging
168 .BR e2fsck ).
169 .TP
170 .B \-D
171 Optimize directories in filesystem.  This option causes e2fsck to
172 try to optimize all directories, either by reindexing them if the
173 filesystem supports directory indexing,  or by sorting and compressing
174 directories for smaller directories, or for filesystems using
175 traditional linear directories.
176 .IP
177 Even without the
178 .B \-D
179 option,
180 .B e2fsck
181 may sometimes optimize a few directories --- for example, if
182 directory indexing is enabled and a directory is not indexed and would
183 benefit from being indexed, or if the index structures are corrupted
184 and need to be rebuilt.  The
185 .B \-D
186 option forces all directories in the filesystem to be optimized.  This can
187 sometimes make them a little smaller and slightly faster to search, but
188 in practice, you should rarely need to use this option.
189 .IP
190 The
191 .B \-D
192 option will detect directory entries with duplicate names in a single
193 directory, which e2fsck normally does not enforce for performance reasons.
194 .TP
195 .BI \-E " extended_options"
196 Set e2fsck extended options.  Extended options are comma
197 separated, and may take an argument using the equals ('=') sign.  The 
198 following options are supported:
199 .RS 1.2i
200 .TP
201 .BI ea_ver= extended_attribute_version
202 Set the version of the extended attribute blocks which
203 .B e2fsck
204 will require while checking the filesystem.  The version number may 
205 be 1 or 2.  The default extended attribute version format is 2.
206 .TP
207 .BI journal_only
208 Only replay the journal if required, but do not perform any further checks
209 or repairs.
210 .TP
211 .BI fragcheck
212 During pass 1, print a detailed report of any discontiguous blocks for
213 files in the filesystem.
214 .TP
215 .BI discard
216 Attempt to discard free blocks and unused inode blocks after the full
217 filesystem check (discarding blocks is useful on solid state devices and sparse
218 / thin-provisioned storage). Note that discard is done in pass 5 AFTER the
219 filesystem has been fully checked and only if it does not contain recognizable
220 errors. However there might be cases where
221 .B e2fsck
222 does not fully recognize a problem and hence in this case this
223 option may prevent you from further manual data recovery.
224 .TP
225 .BI nodiscard
226 Do not attempt to discard free blocks and unused inode blocks. This option is
227 exactly the opposite of discard option. This is set as default.
228 .TP
229 .BI readahead_kb
230 Use this many KiB of memory to pre-fetch metadata in the hopes of reducing
231 e2fsck runtime.  By default, this is set to the size of two block groups' inode
232 tables (typically 4MiB on a regular ext4 filesystem); if this amount is more
233 than 1/50th of total physical memory, readahead is disabled.  Set this to zero
234 to disable readahead entirely.
235 .TP
236 .BI bmap2extent
237 Convert block-mapped files to extent-mapped files.
238 .TP
239 .BI fixes_only
240 Only fix damaged metadata; do not optimize htree directories or compress
241 extent trees.  This option is incompatible with the -D and -E bmap2extent
242 options.
243 .RE
244 .TP
245 .B \-f
246 Force checking even if the file system seems clean.
247 .TP
248 .B \-F
249 Flush the filesystem device's buffer caches before beginning.  Only
250 really useful for doing 
251 .B e2fsck 
252 time trials.
253 @JDEV@.TP
254 @JDEV@.BI \-j " external-journal"
255 @JDEV@Set the pathname where the external-journal for this filesystem can be
256 @JDEV@found.
257 .TP
258 .BI \-k
259 When combined with the 
260 .B \-c
261 option, any existing bad blocks in the bad blocks list are preserved,
262 and any new bad blocks found by running
263 .BR badblocks (8) 
264 will be added to the existing bad blocks list.
265 .TP
266 .BI \-l " filename"
267 Add the block numbers listed in the file specified by 
268 .I filename
269 to the list of bad blocks.  The format of this file is the same as the
270 one generated by the 
271 .BR badblocks (8)
272 program.  Note that the block numbers are based on the blocksize
273 of the filesystem.  Hence, 
274 .BR badblocks (8)
275 must be given the blocksize of the filesystem in order to obtain correct
276 results.  As a result, it is much simpler and safer to use the 
277 .B -c
278 option to 
279 .BR e2fsck ,
280 since it will assure that the correct parameters are passed to the
281 .B badblocks
282 program.
283 .TP
284 .BI \-L " filename"
285 Set the bad blocks list to be the list of blocks specified by 
286 .IR filename .
287 (This option is the same as the 
288 .B \-l
289 option, except the bad blocks list is cleared before the blocks listed
290 in the file are added to the bad blocks list.)
291 .TP
292 .B \-n
293 Open the filesystem read-only, and assume an answer of `no' to all
294 questions.  Allows
295 .B e2fsck
296 to be used non-interactively.  This option
297 may not be specified at the same time as the 
298 .B \-p
299 or
300 .B \-y
301 options.
302 .TP
303 .B \-p
304 Automatically repair ("preen") the file system.  This option will cause
305 .B e2fsck
306 to automatically
307 fix any filesystem problems that can be safely fixed without human
308 intervention.  If 
309 .B e2fsck
310 discovers a problem which may require the system administrator
311 to take additional corrective action, 
312 .B e2fsck
313 will print a description of the problem and then exit with the value 4
314 logically or'ed into the exit code.  (See the \fBEXIT CODE\fR section.)
315 This option is normally used by the system's boot scripts.  It may not 
316 be specified at the same time as the
317 .B \-n
318 or
319 .B \-y
320 options.
321 .TP
322 .B \-r
323 This option does nothing at all; it is provided only for backwards
324 compatibility.
325 .TP
326 .B \-t
327 Print timing statistics for
328 .BR e2fsck .
329 If this option is used twice, additional timing statistics are printed
330 on a pass by pass basis.
331 .TP
332 .B \-v
333 Verbose mode.
334 .TP
335 .B \-V
336 Print version information and exit.
337 .TP
338 .B \-y
339 Assume an answer of `yes' to all questions; allows 
340 .B e2fsck
341 to be used non-interactively.  This option
342 may not be specified at the same time as the 
343 .B \-n
344 or
345 .B \-p
346 options.
347 .TP
348 .BI \-z " undo_file"
349 Before overwriting a file system block, write the old contents of the block to
350 an undo file.  This undo file can be used with e2undo(8) to restore the old
351 contents of the file system should something go wrong.  If the empty string is
352 passed as the undo_file argument, the undo file will be written to a file named
353 e2fsck-\fIdevice\fR.e2undo in the directory specified via the
354 \fIE2FSPROGS_UNDO_DIR\fR environment variable.
355
356 WARNING: The undo file cannot be used to recover from a power or system crash.
357 .SH EXIT CODE
358 The exit code returned by
359 .B e2fsck
360 is the sum of the following conditions:
361 .br
362 \       0\      \-\ No errors
363 .br
364 \       1\      \-\ File system errors corrected
365 .br
366 \       2\      \-\ File system errors corrected, system should
367 .br
368 \       \       \ \ be rebooted
369 .br
370 \       4\      \-\ File system errors left uncorrected
371 .br
372 \       8\      \-\ Operational error
373 .br
374 \       16\     \-\ Usage or syntax error
375 .br
376 \       32\     \-\ E2fsck canceled by user request
377 .br
378 \       128\    \-\ Shared library error
379 .br
380 .SH SIGNALS
381 The following signals have the following effect when sent to 
382 .BR e2fsck .
383 .TP
384 .B SIGUSR1
385 This signal causes
386 .B e2fsck
387 to start displaying a completion bar or emitting progress information.  
388 (See discussion of the 
389 .B \-C
390 option.)
391 .TP
392 .B SIGUSR2
393 This signal causes
394 .B e2fsck 
395 to stop displaying a completion bar or emitting progress information.
396 .SH REPORTING BUGS
397 Almost any piece of software will have bugs.  If you manage to find a
398 filesystem which causes 
399 .B e2fsck
400 to crash, or which 
401 .B e2fsck
402 is unable to repair, please report it to the author.
403 .PP
404 Please include as much information as possible in your bug report.
405 Ideally, include a complete transcript of the
406 .B e2fsck
407 run, so I can see exactly what error messages are displayed.  (Make sure
408 the messages printed by 
409 .B e2fsck 
410 are in English; if your system has been
411 configured so that 
412 .BR e2fsck 's
413 messages have been translated into another language, please set the the
414 .B LC_ALL
415 environment variable to
416 .B C
417 so that the transcript of e2fsck's output will be useful to me.)
418 If you
419 have a writable filesystem where the transcript can be stored, the 
420 .BR script (1)
421 program is a handy way to save the output of
422 .B e2fsck
423 to a file.
424 .PP
425 It is also useful to send the output of 
426 .BR dumpe2fs (8).
427 If a specific inode or inodes seems to be giving 
428 .B e2fsck 
429 trouble, try running the
430 .BR debugfs (8)
431 command and send the output of the 
432 .BR stat (1u)
433 command run on the relevant inode(s).  If the inode is a directory, the 
434 .B debugfs
435 .I dump
436 command will allow you to extract the contents of the directory inode,
437 which can sent to me after being first run through
438 .BR uuencode (1).  
439 The most useful data you can send to help reproduce
440 the bug is a compressed raw image dump of the filesystem, generated using
441 .BR e2image (8).
442 See the 
443 .BR e2image (8)
444 man page for more details.
445 .PP
446 Always include the full version string which 
447 .B e2fsck
448 displays when it is run, so I know which version you are running.
449 .SH AUTHOR
450 This version of 
451 .B e2fsck
452 was written by Theodore Ts'o <tytso@mit.edu>.
453 .SH SEE ALSO
454 .BR e2fsck.conf (5),
455 .BR badblocks (8),
456 .BR dumpe2fs (8),
457 .BR debugfs (8),
458 .BR e2image (8),
459 .BR mke2fs (8),
460 .BR tune2fs (8)