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 ] 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  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

OPTIONS

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       -f     Force checking even if the file system seems clean.
124
125       -F     Flush the filesystem device's buffer  caches  before  beginning.
126              Only really useful for doing e2fsck time trials.
127
128       -j external-journal
129              Set  the pathname where the external-journal for this filesystem
130              can be found.
131
132       -k     When combined with the -c option, any existing bad blocks in the
133              bad  blocks  list are preserved, and any new bad blocks found by
134              running badblocks(8) will be added to the  existing  bad  blocks
135              list.
136
137       -l filename
138              Add  the  block numbers listed in the file specified by filename
139              to the list of bad blocks.  The format of this file is the  same
140              as the one generated by the badblocks(8) program.  Note that the
141              block numbers are based on  the  blocksize  of  the  filesystem.
142              Hence,  badblocks(8) must be given the blocksize of the filesys‐
143              tem in order to obtain correct results.  As a result, it is much
144              simpler  and safer to use the -c option to e2fsck, since it will
145              assure that the correct parameters are passed to  the  badblocks
146              program.
147
148       -L filename
149              Set  the  bad  blocks list to be the list of blocks specified by
150              filename.  (This option is the same as the -l option, except the
151              bad  blocks list is cleared before the blocks listed in the file
152              are added to the bad blocks list.)
153
154       -n     Open the filesystem read-only, and assume an answer of  `no'  to
155              all  questions.   Allows  e2fsck  to  be used non-interactively.
156              This option may not be specified at the same time as the  -p  or
157              -y options.
158
159       -p     Automatically  repair  ("preen")  the  file system.  This option
160              will cause e2fsck to automatically fix any  filesystem  problems
161              that  can be safely fixed without human intervention.  If e2fsck
162              discovers a problem which may require the  system  administrator
163              to  take  additional  corrective  action,  e2fsck  will  print a
164              description of the problem and then exit with the value 4  logi‐
165              cally  or'ed  into  the exit code.  (See the EXIT CODE section.)
166              This option is normally used by the system's boot  scripts.   It
167              may not be specified at the same time as the -n or -y options.
168
169       -r     This  option  does nothing at all; it is provided only for back‐
170              wards compatibility.
171
172       -t     Print timing statistics for e2fsck.   If  this  option  is  used
173              twice,  additional  timing  statistics  are printed on a pass by
174              pass basis.
175
176       -v     Verbose mode.
177
178       -V     Print version information and exit.
179
180       -y     Assume an answer of `yes' to all questions; allows e2fsck to  be
181              used non-interactively.  This option may not be specified at the
182              same time as the -n or -p options.
183

EXIT CODE

185       The exit code returned by e2fsck is the sum  of  the  following  condi‐
186       tions:
187            0    - No errors
188            1    - File system errors corrected
189            2    - File system errors corrected, system should
190                   be rebooted
191            4    - File system errors left uncorrected
192            8    - Operational error
193            16   - Usage or syntax error
194            32   - E2fsck canceled by user request
195            128  - Shared library error
196

SIGNALS

198       The following signals have the following effect when sent to e2fsck.
199
200       SIGUSR1
201              This  signal  causes e2fsck to start displaying a completion bar
202              or emitting progress information.  (See  discussion  of  the  -C
203              option.)
204
205       SIGUSR2
206              This signal causes e2fsck to stop displaying a completion bar or
207              emitting progress information.
208

REPORTING BUGS

210       Almost any piece of software will have bugs.  If you manage to  find  a
211       filesystem  which  causes e2fsck to crash, or which e2fsck is unable to
212       repair, please report it to the author.
213
214       Please include as much information as  possible  in  your  bug  report.
215       Ideally,  include a complete transcript of the e2fsck run, so I can see
216       exactly what error messages are displayed.   (Make  sure  the  messages
217       printed by e2fsck are in English; if your system has been configured so
218       that e2fsck's messages have  been  translated  into  another  language,
219       please  set  the the LC_ALL environment variable to C so that the tran‐
220       script of e2fsck's output will  be  useful  to  me.)   If  you  have  a
221       writable  filesystem  where the transcript can be stored, the script(1)
222       program is a handy way to save the output of e2fsck to a file.
223
224       It is also useful to send the output of  dumpe2fs(8).   If  a  specific
225       inode  or  inodes  seems  to  be giving e2fsck trouble, try running the
226       debugfs(8) command and send the output of the stat(1u) command  run  on
227       the  relevant  inode(s).  If the inode is a directory, the debugfs dump
228       command will allow you to extract the contents of the directory  inode,
229       which  can  sent  to me after being first run through uuencode(1).  The
230       most useful data you can send to help reproduce the bug is a compressed
231       raw  image dump of the filesystem, generated using e2image(8).  See the
232       e2image(8) man page for more details.
233
234       Always include the full version string which e2fsck displays when it is
235       run, so I know which version you are running.
236

AUTHOR

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

SEE ALSO

241       e2fsck.conf(5),   badblocks(8),  dumpe2fs(8),  debugfs(8),  e2image(8),
242       mke2fs(8), tune2fs(8)
243
244
245
246E2fsprogs version 1.41.12          May 2010                          E2FSCK(8)
Impressum