1E2FSCK(8)                   System Manager's Manual                  E2FSCK(8)
2
3
4

NAME

6       e2fsck - check a Linux ext2/ext3/ext4 file system
7

SYNOPSIS

9       e2fsck  [  -pacnyrdfkvtDFV ] [ -b superblock ] [ -B blocksize ] [ -l|-L
10       bad_blocks_file ] [ -C fd ] [ -j external-journal ] [  -E  extended_op‐
11       tions ] [ -z undo_file ] device
12

DESCRIPTION

14       e2fsck is used to check the ext2/ext3/ext4 family of file systems.  For
15       ext3 and ext4 file systems 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 file systems that use journaling, e2fsck
19       will normally replay the journal and exit, unless its superblock  indi‐
20       cates that further checking is required.
21
22       device  is a block device (e.g., /dev/sdc1) or file containing the file
23       system.
24
25       Note that in general it is not safe to run e2fsck on mounted file  sys‐
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 file system is
29       mounted.   If e2fsck asks whether or not you should check a file system
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
34       If  e2fsck  is run in interactive mode (meaning that none of -y, -n, or
35       -p are specified), the program will ask the user to  fix  each  problem
36       found  in  the  file system.  A response of 'y' will fix the error; 'n'
37       will leave the error unfixed; and 'a' will fix the problem and all sub‐
38       sequent  problems;  pressing  Enter  will  proceed with the default re‐
39       sponse, which is printed before the question mark.  Pressing  Control-C
40       terminates e2fsck immediately.
41

OPTIONS

43       -a     This  option  does  the same thing as the -p option.  It is pro‐
44              vided for backwards compatibility only;  it  is  suggested  that
45              people use -p option whenever possible.
46
47       -b superblock
48              Instead  of  using the normal superblock, use an alternative su‐
49              perblock specified by superblock.  This option is normally  used
50              when the primary superblock has been corrupted.  The location of
51              backup superblocks is dependent on the file system's  blocksize,
52              the  number of blocks per group, and features such as sparse_su‐
53              per.
54
55              Additional backup superblocks can be  determined  by  using  the
56              mke2fs  program  using  the -n option to print out where the su‐
57              perblocks exist, supposing mke2fs  is  supplied  with  arguments
58              that  are  consistent with the file system's layout (e.g. block‐
59              size, blocks per group, sparse_super, etc.).
60
61              If an alternative superblock is specified and the file system is
62              not opened read-only, e2fsck will make sure that the primary su‐
63              perblock is updated appropriately upon completion  of  the  file
64              system check.
65
66       -B blocksize
67              Normally,  e2fsck will search for the superblock at various dif‐
68              ferent block sizes in an attempt to find the  appropriate  block
69              size.   This  search  can  be fooled in some cases.  This option
70              forces e2fsck to only try locating the superblock at a  particu‐
71              lar blocksize.  If the superblock is not found, e2fsck will ter‐
72              minate with a fatal error.
73
74       -c     This option causes e2fsck to use badblocks(8) program  to  do  a
75              read-only  scan  of  the device in order to find any bad blocks.
76              If any bad blocks are found, they are added to the bad block in‐
77              ode to prevent them from being allocated to a file or directory.
78              If this option is specified twice, then the bad block scan  will
79              be done using a non-destructive read-write test.
80
81       -C fd  This option causes e2fsck to write completion information to the
82              specified file descriptor so that the progress of the file  sys‐
83              tem  check  can  be monitored.  This option is typically used by
84              programs which are running e2fsck.  If the file descriptor  num‐
85              ber is negative, then absolute value of the file descriptor will
86              be used, and the progress information will  be  suppressed  ini‐
87              tially.  It can later be enabled by sending the e2fsck process a
88              SIGUSR1 signal.  If the file descriptor specified is  0,  e2fsck
89              will print a completion bar as it goes about its business.  This
90              requires that e2fsck is running on a video console or terminal.
91
92       -d     Print  debugging  output  (useless  unless  you  are   debugging
93              e2fsck).
94
95       -D     Optimize  directories in file system.  This option causes e2fsck
96              to try to optimize all directories, either by  re-indexing  them
97              if  the  file system supports directory indexing,  or by sorting
98              and compressing directories for smaller directories, or for file
99              systems using traditional linear directories.
100
101              Even  without the -D option, e2fsck may sometimes optimize a few
102              directories --- for example, if directory  indexing  is  enabled
103              and  a directory is not indexed and would benefit from being in‐
104              dexed, or if the index structures are corrupted and need  to  be
105              rebuilt.   The -D option forces all directories in the file sys‐
106              tem to be optimized.  This can  sometimes  make  them  a  little
107              smaller  and  slightly  faster  to  search, but in practice, you
108              should rarely need to use this option.
109
110              The -D option will detect directory entries with duplicate names
111              in  a  single  directory, which e2fsck normally does not enforce
112              for performance reasons.
113
114       -E extended_options
115              Set e2fsck extended options.  Extended options are  comma  sepa‐
116              rated,  and  may  take  an argument using the equals ('=') sign.
117              The following options are supported:
118
119                   ea_ver=extended_attribute_version
120                          Set the version of  the  extended  attribute  blocks
121                          which  e2fsck  will  require while checking the file
122                          system.  The version number may be 1 or 2.  The  de‐
123                          fault extended attribute version format is 2.
124
125                   journal_only
126                          Only replay the journal if required, but do not per‐
127                          form any further checks or repairs.
128
129                   fragcheck
130                          During pass 1, print a detailed report of  any  dis‐
131                          contiguous blocks for files in the file system.
132
133                   discard
134                          Attempt  to  discard  free  blocks  and unused inode
135                          blocks after the full file system check  (discarding
136                          blocks is useful on solid state devices and sparse /
137                          thin-provisioned storage). Note that discard is done
138                          in  pass  5  AFTER  the  file  system has been fully
139                          checked and only if it does not contain recognizable
140                          errors.  However  there  might be cases where e2fsck
141                          does not fully recognize a problem and hence in this
142                          case this option may prevent you from further manual
143                          data recovery.
144
145                   nodiscard
146                          Do not attempt to discard free blocks and unused in‐
147                          ode  blocks.  This option is exactly the opposite of
148                          discard option. This is set as default.
149
150                   no_optimize_extents
151                          Do not offer to optimize the extent tree  by  elimi‐
152                          nating unnecessary width or depth.  This can also be
153                          enabled in the options section of /etc/e2fsck.conf.
154
155                   optimize_extents
156                          Offer to optimize the extent tree by eliminating un‐
157                          necessary  width  or depth.  This is the default un‐
158                          less otherwise specified in /etc/e2fsck.conf.
159
160                   inode_count_fullmap
161                          Trade off using memory for  speed  when  checking  a
162                          file  system  with  a  large  number  of hard-linked
163                          files.  The amount of  memory  required  is  propor‐
164                          tional  to  the number of inodes in the file system.
165                          For large file systems, this  can  be  gigabytes  of
166                          memory.   (For  example, a 40TB file system with 2.8
167                          billion inodes will consume  an  additional  5.7  GB
168                          memory if this optimization is enabled.)  This opti‐
169                          mization can also be enabled in the options  section
170                          of /etc/e2fsck.conf.
171
172                   no_inode_count_fullmap
173                          Disable  the inode_count_fullmap optimization.  This
174                          is  the  default  unless  otherwise   specified   in
175                          /etc/e2fsck.conf.
176
177                   readahead_kb
178                          Use this many KiB of memory to pre-fetch metadata in
179                          the hopes of reducing e2fsck runtime.   By  default,
180                          this  is  set to the size of two block groups' inode
181                          tables (typically 4MiB on a regular ext4  file  sys‐
182                          tem);  if  this  amount is more than 1/50th of total
183                          physical memory, readahead is disabled.  Set this to
184                          zero to disable readahead entirely.
185
186                   bmap2extent
187                          Convert block-mapped files to extent-mapped files.
188
189                   fixes_only
190                          Only fix damaged metadata; do not optimize htree di‐
191                          rectories or compress extent trees.  This option  is
192                          incompatible with the -D and -E bmap2extent options.
193
194                   check_encoding
195                          Force  verification of encoded filenames in case-in‐
196                          sensitive directories.  This is the default mode  if
197                          the file system has the strict flag enabled.
198
199                   unshare_blocks
200                          If  the  file  system  has  shared  blocks, with the
201                          shared blocks read-only feature enabled,  then  this
202                          will  unshare  all shared blocks and unset the read-
203                          only feature bit. If there is not enough free  space
204                          then  the  operation  will fail.  If the file system
205                          does not have the read-only  feature  bit,  but  has
206                          shared  blocks anyway, then this option will have no
207                          effect. Note when using this option, if there is  no
208                          free  space  to  clone blocks, there is no prompt to
209                          delete files and instead the operation will fail.
210
211                          Note that unshare_blocks implies the "-f" option  to
212                          ensure  that  all  passes  are run. Additionally, if
213                          "-n" is also specified, e2fsck will simulate  trying
214                          to  allocate  enough  space  to deduplicate. If this
215                          fails, the exit code will be non-zero.
216
217       -f     Force checking even if the file system seems clean.
218
219       -F     Flush the file system device's buffer caches  before  beginning.
220              Only really useful for doing e2fsck time trials.
221
222       -j external-journal
223              Set the pathname where the external-journal for this file system
224              can be found.
225
226       -k     When combined with the -c option, any existing bad blocks in the
227              bad  blocks  list are preserved, and any new bad blocks found by
228              running badblocks(8) will be added to the  existing  bad  blocks
229              list.
230
231       -l filename
232              Add  the  block numbers listed in the file specified by filename
233              to the list of bad blocks.  The format of this file is the  same
234              as the one generated by the badblocks(8) program.  Note that the
235              block numbers are based on the blocksize  of  the  file  system.
236              Hence, badblocks(8) must be given the blocksize of the file sys‐
237              tem in order to obtain correct results.  As a result, it is much
238              simpler  and safer to use the -c option to e2fsck, since it will
239              assure that the correct parameters are passed to  the  badblocks
240              program.
241
242       -L filename
243              Set  the  bad  blocks list to be the list of blocks specified by
244              filename.  (This option is the same as the -l option, except the
245              bad  blocks list is cleared before the blocks listed in the file
246              are added to the bad blocks list.)
247
248       -n     Open the file system read-only, and assume an answer of `no'  to
249              all  questions.   Allows  e2fsck  to  be used non-interactively.
250              This option may not be specified at the same time as the  -p  or
251              -y options.
252
253       -p     Automatically  repair  ("preen")  the  file system.  This option
254              will cause e2fsck to automatically fix any file system  problems
255              that  can be safely fixed without human intervention.  If e2fsck
256              discovers a problem which may require the  system  administrator
257              to  take  additional  corrective action, e2fsck will print a de‐
258              scription of the problem and then exit with the  value  4  logi‐
259              cally  or'ed  into  the exit code.  (See the EXIT CODE section.)
260              This option is normally used by the system's boot  scripts.   It
261              may not be specified at the same time as the -n or -y options.
262
263       -r     This  option  does nothing at all; it is provided only for back‐
264              wards compatibility.
265
266       -t     Print timing statistics for e2fsck.   If  this  option  is  used
267              twice,  additional  timing  statistics  are printed on a pass by
268              pass basis.
269
270       -v     Verbose mode.
271
272       -V     Print version information and exit.
273
274       -y     Assume an answer of `yes' to all questions; allows e2fsck to  be
275              used non-interactively.  This option may not be specified at the
276              same time as the -n or -p options.
277
278       -z undo_file
279              Before overwriting a file system block, write the  old  contents
280              of  the  block to an undo file.  This undo file can be used with
281              e2undo(8) to restore the old contents of the file system  should
282              something  go  wrong.   If  the  empty  string  is passed as the
283              undo_file argument, the undo file will  be  written  to  a  file
284              named  e2fsck-device.e2undo  in  the directory specified via the
285              E2FSPROGS_UNDO_DIR environment variable.
286
287              WARNING: The undo file cannot be used to recover from a power or
288              system crash.
289

EXIT CODE

291       The  exit  code  returned  by e2fsck is the sum of the following condi‐
292       tions:
293            0    - No errors
294            1    - File system errors corrected
295            2    - File system errors corrected, system should
296                   be rebooted
297            4    - File system errors left uncorrected
298            8    - Operational error
299            16   - Usage or syntax error
300            32   - E2fsck canceled by user request
301            128  - Shared library error
302

SIGNALS

304       The following signals have the following effect when sent to e2fsck.
305
306       SIGUSR1
307              This signal causes e2fsck to start displaying a  completion  bar
308              or emitting progress information.  (See discussion of the -C op‐
309              tion.)
310
311       SIGUSR2
312              This signal causes e2fsck to stop displaying a completion bar or
313              emitting progress information.
314

REPORTING BUGS

316       Almost  any  piece of software will have bugs.  If you manage to find a
317       file system which causes e2fsck to crash, or which e2fsck is unable  to
318       repair, please report it to the author.
319
320       Please  include  as  much  information  as possible in your bug report.
321       Ideally, include a complete transcript of the e2fsck run, so I can  see
322       exactly  what  error  messages  are displayed.  (Make sure the messages
323       printed by e2fsck are in English; if your system has been configured so
324       that  e2fsck's  messages  have  been  translated into another language,
325       please set the the LC_ALL environment variable to C so that  the  tran‐
326       script  of  e2fsck's  output  will  be  useful  to  me.)  If you have a
327       writable file system where the transcript can be stored, the  script(1)
328       program is a handy way to save the output of e2fsck to a file.
329
330       It is also useful to send the output of dumpe2fs(8).  If a specific in‐
331       ode or inodes seems to be giving e2fsck trouble, try  running  the  de‐
332       bugfs(8) command and send the output of the stat(1u) command run on the
333       relevant inode(s).  If the inode is a directory, the debugfs dump  com‐
334       mand  will  allow  you  to extract the contents of the directory inode,
335       which can sent to me after being first run  through  uuencode(1).   The
336       most useful data you can send to help reproduce the bug is a compressed
337       raw image dump of the file system, generated using e2image(8).  See the
338       e2image(8) man page for more details.
339
340       Always include the full version string which e2fsck displays when it is
341       run, so I know which version you are running.
342

ENVIRONMENT

344       E2FSCK_CONFIG
345              Determines  the  location  of  the   configuration   file   (see
346              e2fsck.conf(5)).
347

AUTHOR

349       This version of e2fsck was written by Theodore Ts'o <tytso@mit.edu>.
350

SEE ALSO

352       e2fsck.conf(5),   badblocks(8),  dumpe2fs(8),  debugfs(8),  e2image(8),
353       mke2fs(8), tune2fs(8)
354
355
356
357E2fsprogs version 1.47.0         February 2023                       E2FSCK(8)
Impressum