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