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
11       extended_options ] [ -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 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 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  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
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  filesystem.   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
39       response, which is printed before the question mark.  Pressing Control-
40       C 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
49              superblock specified by superblock.   This  option  is  normally
50              used  when the primary superblock has been corrupted.  The loca‐
51              tion of backup superblocks  is  dependent  on  the  filesystem's
52              blocksize,  the number of blocks per group, and features such as
53              sparse_super.
54
55              Additional backup superblocks can be  determined  by  using  the
56              mke2fs  program  using  the  -n  option  to  print out where the
57              superblocks exist, supposing mke2fs is supplied  with  arguments
58              that  are  consistent  with the filesystem's layout (e.g. block‐
59              size, blocks per group, sparse_super, etc.).
60
61              If an alternative superblock is specified and the filesystem  is
62              not  opened  read-only,  e2fsck  will make sure that the primary
63              superblock is  updated  appropriately  upon  completion  of  the
64              filesystem 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
77              inode  to  prevent them from being allocated to a file or direc‐
78              tory.  If this option is specified twice,  then  the  bad  block
79              scan will 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 filesystem
83              check  can  be monitored.  This option is typically used by pro‐
84              grams which are running e2fsck.  If the file  descriptor  number
85              is  negative, then absolute value of the file descriptor will be
86              used, and the progress information will be suppressed initially.
87              It  can later be enabled by sending the e2fsck process a SIGUSR1
88              signal.  If the file descriptor  specified  is  0,  e2fsck  will
89              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 filesystem.  This option causes e2fsck
96              to try to optimize all directories, either by reindexing them if
97              the  filesystem  supports directory indexing,  or by sorting and
98              compressing directories for smaller directories, or for filesys‐
99              tems 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
104              indexed, or if the index structures are corrupted and need to be
105              rebuilt.  The -D option forces all directories in the filesystem
106              to be optimized.  This can sometimes make them a little  smaller
107              and  slightly  faster  to  search,  but  in practice, you should
108              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
122                          filesystem.  The version number may be 1 or 2.   The
123                          default 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 filesystem.
132
133                   discard
134                          Attempt  to  discard  free  blocks  and unused inode
135                          blocks after the full filesystem  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  filesystem  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
147                          inode 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
157                          unnecessary  width  or  depth.   This is the default
158                          unless 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  filesys‐
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
191                          directories or compress extent trees.   This  option
192                          is  incompatible  with  the  -D  and  -E bmap2extent
193                          options.
194
195                   unshare_blocks
196                          If the filesystem has shared blocks, with the shared
197                          blocks  read-only  feature  enabled,  then this will
198                          unshare all shared blocks and  unset  the  read-only
199                          feature  bit. If there is not enough free space then
200                          the operation will fail.  If the filesystem does not
201                          have  the  read-only  feature  bit,  but  has shared
202                          blocks anyway, then this option will have no effect.
203                          Note  when  using  this  option, if there is no free
204                          space to clone blocks, there is no prompt to  delete
205                          files and instead the operation will fail.
206
207                          Note  that unshare_blocks implies the "-f" option to
208                          ensure that all passes  are  run.  Additionally,  if
209                          "-n"  is also specified, e2fsck will simulate trying
210                          to allocate enough space  to  deduplicate.  If  this
211                          fails, the exit code will be non-zero.
212
213       -f     Force checking even if the file system seems clean.
214
215       -F     Flush  the  filesystem  device's buffer caches before beginning.
216              Only really useful for doing e2fsck time trials.
217
218       -j external-journal
219              Set the pathname where the external-journal for this  filesystem
220              can be found.
221
222       -k     When combined with the -c option, any existing bad blocks in the
223              bad blocks list are preserved, and any new bad blocks  found  by
224              running  badblocks(8)  will  be added to the existing bad blocks
225              list.
226
227       -l filename
228              Add the block numbers listed in the file specified  by  filename
229              to  the list of bad blocks.  The format of this file is the same
230              as the one generated by the badblocks(8) program.  Note that the
231              block  numbers  are  based  on  the blocksize of the filesystem.
232              Hence, badblocks(8) must be given the blocksize of the  filesys‐
233              tem in order to obtain correct results.  As a result, it is much
234              simpler and safer to use the -c option to e2fsck, since it  will
235              assure  that  the correct parameters are passed to the badblocks
236              program.
237
238       -L filename
239              Set the bad blocks list to be the list of  blocks  specified  by
240              filename.  (This option is the same as the -l option, except the
241              bad blocks list is cleared before the blocks listed in the  file
242              are added to the bad blocks list.)
243
244       -n     Open  the  filesystem read-only, and assume an answer of `no' to
245              all questions.  Allows  e2fsck  to  be  used  non-interactively.
246              This  option  may not be specified at the same time as the -p or
247              -y options.
248
249       -p     Automatically repair ("preen") the  file  system.   This  option
250              will  cause  e2fsck to automatically fix any filesystem problems
251              that can be safely fixed without human intervention.  If  e2fsck
252              discovers  a  problem which may require the system administrator
253              to take  additional  corrective  action,  e2fsck  will  print  a
254              description  of the problem and then exit with the value 4 logi‐
255              cally or'ed into the exit code.  (See the  EXIT  CODE  section.)
256              This  option  is normally used by the system's boot scripts.  It
257              may not be specified at the same time as the -n or -y options.
258
259       -r     This option does nothing at all; it is provided only  for  back‐
260              wards compatibility.
261
262       -t     Print  timing  statistics  for  e2fsck.   If this option is used
263              twice, additional timing statistics are printed  on  a  pass  by
264              pass basis.
265
266       -v     Verbose mode.
267
268       -V     Print version information and exit.
269
270       -y     Assume  an answer of `yes' to all questions; allows e2fsck to be
271              used non-interactively.  This option may not be specified at the
272              same time as the -n or -p options.
273
274       -z undo_file
275              Before  overwriting  a file system block, write the old contents
276              of the block to an undo file.  This undo file can be  used  with
277              e2undo(8)  to restore the old contents of the file system should
278              something go wrong.  If  the  empty  string  is  passed  as  the
279              undo_file  argument,  the  undo  file  will be written to a file
280              named e2fsck-device.e2undo in the directory  specified  via  the
281              E2FSPROGS_UNDO_DIR environment variable.
282
283              WARNING: The undo file cannot be used to recover from a power or
284              system crash.
285

EXIT CODE

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

SIGNALS

300       The following signals have the following effect when sent to e2fsck.
301
302       SIGUSR1
303              This  signal  causes e2fsck to start displaying a completion bar
304              or emitting progress information.  (See  discussion  of  the  -C
305              option.)
306
307       SIGUSR2
308              This signal causes e2fsck to stop displaying a completion bar or
309              emitting progress information.
310

REPORTING BUGS

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

ENVIRONMENT

340       E2FSCK_CONFIG
341              Determines   the   location   of  the  configuration  file  (see
342              e2fsck.conf(5)).
343

AUTHOR

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

SEE ALSO

348       e2fsck.conf(5),  badblocks(8),  dumpe2fs(8),  debugfs(8),   e2image(8),
349       mke2fs(8), tune2fs(8)
350
351
352
353E2fsprogs version 1.44.3              2018                           E2FSCK(8)
Impressum