1E2FSCK(8) System Manager's Manual E2FSCK(8)
2
3
4
6 e2fsck - check a Linux ext2/ext3/ext4 file system
7
9 e2fsck [ -pacnyrdfkvtDFV ] [ -b superblock ] [ -B blocksize ] [ -l|-L
10 bad_blocks_file ] [ -C fd ] [ -j external-journal ] [ -E
11 extended_options ] device
12
14 e2fsck is used to check the ext2/ext3/ext4 family of file systems. For
15 ext3 and ext4 filesystems that use a journal, if the system has been
16 shut down uncleanly without any errors, normally, after replaying the
17 committed transactions in the journal, the file system should be
18 marked as clean. Hence, for filesystems that use journalling, e2fsck
19 will normally replay the journal and exit, unless its superblock indi‐
20 cates that further checking is required.
21
22 device is the device file where the filesystem is stored (e.g.
23 /dev/hdc1).
24
25 Note that in general it is not safe to run e2fsck on mounted filesys‐
26 tems. The only exception is if the -n option is specified, and -c, -l,
27 or -L options are not specified. However, even if it is safe to do
28 so, the results printed by e2fsck are not valid if the filesystem is
29 mounted. If e2fsck asks whether or not you should check a filesystem
30 which is mounted, the only correct answer is ``no''. Only experts who
31 really know what they are doing should consider answering this question
32 in any other way.
33
35 -a This option does the same thing as the -p option. It is pro‐
36 vided for backwards compatibility only; it is suggested that
37 people use -p option whenever possible.
38
39 -b superblock
40 Instead of using the normal superblock, use an alternative
41 superblock specified by superblock. This option is normally
42 used when the primary superblock has been corrupted. The loca‐
43 tion of the backup superblock is dependent on the filesystem's
44 blocksize. For filesystems with 1k blocksizes, a backup
45 superblock can be found at block 8193; for filesystems with 2k
46 blocksizes, at block 16384; and for 4k blocksizes, at block
47 32768.
48
49 Additional backup superblocks can be determined by using the
50 mke2fs program using the -n option to print out where the
51 superblocks were created. The -b option to mke2fs, which spec‐
52 ifies blocksize of the filesystem must be specified in order for
53 the superblock locations that are printed out to be accurate.
54
55 If an alternative superblock is specified and the filesystem is
56 not opened read-only, e2fsck will make sure that the primary
57 superblock is updated appropriately upon completion of the
58 filesystem check.
59
60 -B blocksize
61 Normally, e2fsck will search for the superblock at various dif‐
62 ferent block sizes in an attempt to find the appropriate block
63 size. This search can be fooled in some cases. This option
64 forces e2fsck to only try locating the superblock at a particu‐
65 lar blocksize. If the superblock is not found, e2fsck will ter‐
66 minate with a fatal error.
67
68 -c This option causes e2fsck to use badblocks(8) program to do a
69 read-only scan of the device in order to find any bad blocks.
70 If any bad blocks are found, they are added to the bad block
71 inode to prevent them from being allocated to a file or direc‐
72 tory. If this option is specified twice, then the bad block
73 scan will be done using a non-destructive read-write test.
74
75 -C fd This option causes e2fsck to write completion information to the
76 specified file descriptor so that the progress of the filesystem
77 check can be monitored. This option is typically used by pro‐
78 grams which are running e2fsck. If the file descriptor number
79 is negative, then absolute value of the file descriptor will be
80 used, and the progress information will be suppressed initially.
81 It can later be enabled by sending the e2fsck process a SIGUSR1
82 signal. If the file descriptor specified is 0, e2fsck will
83 print a completion bar as it goes about its business. This
84 requires that e2fsck is running on a video console or terminal.
85
86 -d Print debugging output (useless unless you are debugging
87 e2fsck).
88
89 -D Optimize directories in filesystem. This option causes e2fsck
90 to try to optimize all directories, either by reindexing them if
91 the filesystem supports directory indexing, or by sorting and
92 compressing directories for smaller directories, or for filesys‐
93 tems using traditional linear directories.
94
95 Even without the -D option, e2fsck may sometimes optimize a few
96 directories --- for example, if directory indexing is enabled
97 and a directory is not indexed and would benefit from being
98 indexed, or if the index structures are corrupted and need to be
99 rebuilt. The -D option forces all directories in the filesystem
100 to be optimized. This can sometimes make them a little smaller
101 and slightly faster to search, but in practice, you should
102 rarely need to use this option.
103
104 The -D option will detect directory entries with duplicate names
105 in a single directory, which e2fsck normally does not enforce
106 for performance reasons.
107
108 -E extended_options
109 Set e2fsck extended options. Extended options are comma sepa‐
110 rated, and may take an argument using the equals ('=') sign.
111 The following options are supported:
112
113 ea_ver=extended_attribute_version
114 Set the version of the extended attribute blocks
115 which e2fsck will require while checking the
116 filesystem. The version number may be 1 or 2. The
117 default extended attribute version format is 2.
118
119 fragcheck
120 During pass 1, print a detailed report of any dis‐
121 contiguous blocks for files in the filesystem.
122
123 discard
124 Attempt to discard free blocks and unused inode
125 blocks after the full filesystem check (discarding
126 blocks is useful on solid state devices and sparse /
127 thin-provisioned storage). Note that discard is done
128 in pass 5 AFTER the filesystem has been fully
129 checked and only if it does not contain recognizable
130 errors. However there might be cases where e2fsck
131 does not fully recognise a problem and hence in this
132 case this option may prevent you from further manual
133 data recovery.
134
135 nodiscard
136 Do not attempt to discard free blocks and unused
137 inode blocks. This option is exacly the opposite of
138 discard option. This is set as default.
139
140 -f Force checking even if the file system seems clean.
141
142 -F Flush the filesystem device's buffer caches before beginning.
143 Only really useful for doing e2fsck time trials.
144
145 -j external-journal
146 Set the pathname where the external-journal for this filesystem
147 can be found.
148
149 -k When combined with the -c option, any existing bad blocks in the
150 bad blocks list are preserved, and any new bad blocks found by
151 running badblocks(8) will be added to the existing bad blocks
152 list.
153
154 -l filename
155 Add the block numbers listed in the file specified by filename
156 to the list of bad blocks. The format of this file is the same
157 as the one generated by the badblocks(8) program. Note that the
158 block numbers are based on the blocksize of the filesystem.
159 Hence, badblocks(8) must be given the blocksize of the filesys‐
160 tem in order to obtain correct results. As a result, it is much
161 simpler and safer to use the -c option to e2fsck, since it will
162 assure that the correct parameters are passed to the badblocks
163 program.
164
165 -L filename
166 Set the bad blocks list to be the list of blocks specified by
167 filename. (This option is the same as the -l option, except the
168 bad blocks list is cleared before the blocks listed in the file
169 are added to the bad blocks list.)
170
171 -n Open the filesystem read-only, and assume an answer of `no' to
172 all questions. Allows e2fsck to be used non-interactively.
173 This option may not be specified at the same time as the -p or
174 -y options.
175
176 -p Automatically repair ("preen") the file system. This option
177 will cause e2fsck to automatically fix any filesystem problems
178 that can be safely fixed without human intervention. If e2fsck
179 discovers a problem which may require the system administrator
180 to take additional corrective action, e2fsck will print a
181 description of the problem and then exit with the value 4 logi‐
182 cally or'ed into the exit code. (See the EXIT CODE section.)
183 This option is normally used by the system's boot scripts. It
184 may not be specified at the same time as the -n or -y options.
185
186 -r This option does nothing at all; it is provided only for back‐
187 wards compatibility.
188
189 -t Print timing statistics for e2fsck. If this option is used
190 twice, additional timing statistics are printed on a pass by
191 pass basis.
192
193 -v Verbose mode.
194
195 -V Print version information and exit.
196
197 -y Assume an answer of `yes' to all questions; allows e2fsck to be
198 used non-interactively. This option may not be specified at the
199 same time as the -n or -p options.
200
202 The exit code returned by e2fsck is the sum of the following condi‐
203 tions:
204 0 - No errors
205 1 - File system errors corrected
206 2 - File system errors corrected, system should
207 be rebooted
208 4 - File system errors left uncorrected
209 8 - Operational error
210 16 - Usage or syntax error
211 32 - E2fsck canceled by user request
212 128 - Shared library error
213
215 The following signals have the following effect when sent to e2fsck.
216
217 SIGUSR1
218 This signal causes e2fsck to start displaying a completion bar
219 or emitting progress information. (See discussion of the -C
220 option.)
221
222 SIGUSR2
223 This signal causes e2fsck to stop displaying a completion bar or
224 emitting progress information.
225
227 Almost any piece of software will have bugs. If you manage to find a
228 filesystem which causes e2fsck to crash, or which e2fsck is unable to
229 repair, please report it to the author.
230
231 Please include as much information as possible in your bug report.
232 Ideally, include a complete transcript of the e2fsck run, so I can see
233 exactly what error messages are displayed. (Make sure the messages
234 printed by e2fsck are in English; if your system has been configured so
235 that e2fsck's messages have been translated into another language,
236 please set the the LC_ALL environment variable to C so that the tran‐
237 script of e2fsck's output will be useful to me.) If you have a
238 writable filesystem where the transcript can be stored, the script(1)
239 program is a handy way to save the output of e2fsck to a file.
240
241 It is also useful to send the output of dumpe2fs(8). If a specific
242 inode or inodes seems to be giving e2fsck trouble, try running the
243 debugfs(8) command and send the output of the stat(1u) command run on
244 the relevant inode(s). If the inode is a directory, the debugfs dump
245 command will allow you to extract the contents of the directory inode,
246 which can sent to me after being first run through uuencode(1). The
247 most useful data you can send to help reproduce the bug is a compressed
248 raw image dump of the filesystem, generated using e2image(8). See the
249 e2image(8) man page for more details.
250
251 Always include the full version string which e2fsck displays when it is
252 run, so I know which version you are running.
253
255 This version of e2fsck was written by Theodore Ts'o <tytso@mit.edu>.
256
258 e2fsck.conf(5), badblocks(8), dumpe2fs(8), debugfs(8), e2image(8),
259 mke2fs(8), tune2fs(8)
260
261
262
263E2fsprogs version 1.41.12 May 2010 E2FSCK(8)