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