| 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 "March 2025" "E2fsprogs version 1.47.4" |
| 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 |
[ |
| 30 |
.B \-j |
| 31 |
.I external-journal |
| 32 |
] |
| 33 |
[ |
| 34 |
.B \-E |
| 35 |
.I extended_options |
| 36 |
] |
| 37 |
[ |
| 38 |
.B \-z |
| 39 |
.I undo_file |
| 40 |
] |
| 41 |
.I device |
| 42 |
.SH DESCRIPTION |
| 43 |
.B e2fsck |
| 44 |
is used to check the ext2/ext3/ext4 family of file systems. |
| 45 |
For ext3 and ext4 file systems that use a journal, if the system has been |
| 46 |
shut down uncleanly without any errors, normally, after replaying the |
| 47 |
committed transactions in the journal, the file system should be |
| 48 |
marked as clean. |
| 49 |
Hence, for file systems that use journaling, |
| 50 |
.B e2fsck |
| 51 |
will normally replay the journal and exit, unless its superblock |
| 52 |
indicates that further checking is required. |
| 53 |
.PP |
| 54 |
.I device |
| 55 |
is a block device (e.g., |
| 56 |
.IR /dev/sdc1 ) |
| 57 |
or file containing the file system. |
| 58 |
.PP |
| 59 |
Note that in general it is not safe to run |
| 60 |
.B e2fsck |
| 61 |
on mounted file systems. The only exception is if the |
| 62 |
.B \-n |
| 63 |
option is specified, and |
| 64 |
.BR \-c , |
| 65 |
.BR \-l , |
| 66 |
or |
| 67 |
.B \-L |
| 68 |
options are |
| 69 |
.I not |
| 70 |
specified. |
| 71 |
However, even if it is safe to do so, the results printed by |
| 72 |
.B e2fsck |
| 73 |
are not valid if the file system is mounted. |
| 74 |
If |
| 75 |
.B e2fsck |
| 76 |
asks whether or not you should check a file system which is mounted, |
| 77 |
the only correct answer is ``no''. Only experts who really know what |
| 78 |
they are doing should consider answering this question in any other way. |
| 79 |
.PP |
| 80 |
If |
| 81 |
.B e2fsck |
| 82 |
is run in interactive mode (meaning that none of |
| 83 |
.BR \-y , |
| 84 |
.BR \-n , |
| 85 |
or |
| 86 |
.B \-p |
| 87 |
are specified), the program will ask the user to fix each problem found in the |
| 88 |
file system. A response of \&'y' will fix the error; \&'n' will leave the error |
| 89 |
unfixed; and \&'a' will fix the problem and all subsequent problems; pressing |
| 90 |
Enter will proceed with the default response, which is printed before the |
| 91 |
question mark. Pressing Control-C terminates e2fsck immediately. |
| 92 |
.SH OPTIONS |
| 93 |
.TP |
| 94 |
.B \-a |
| 95 |
This option does the same thing as the |
| 96 |
.B \-p |
| 97 |
option. It is provided for backwards compatibility only; it is |
| 98 |
suggested that people use |
| 99 |
.B \-p |
| 100 |
option whenever possible. |
| 101 |
.TP |
| 102 |
.BI \-b " superblock" |
| 103 |
Instead of using the normal superblock, use an alternative superblock |
| 104 |
specified by |
| 105 |
.IR superblock . |
| 106 |
This option is normally used when the primary superblock has been |
| 107 |
corrupted. The location of backup superblocks is dependent on the |
| 108 |
file system's blocksize, the number of blocks per group, and features |
| 109 |
such as |
| 110 |
.BR sparse_super . |
| 111 |
.IP |
| 112 |
Additional backup superblocks can be determined by using the |
| 113 |
.B mke2fs |
| 114 |
program using the |
| 115 |
.B \-n |
| 116 |
option to print out where the superblocks exist, supposing |
| 117 |
.B mke2fs |
| 118 |
is supplied with arguments that are consistent with the file system's layout |
| 119 |
(e.g.\& blocksize, blocks per group, |
| 120 |
.BR sparse_super , |
| 121 |
etc.). |
| 122 |
.IP |
| 123 |
If an alternative superblock is specified and |
| 124 |
the file system is not opened read-only, e2fsck will make sure that the |
| 125 |
primary superblock is updated appropriately upon completion of the |
| 126 |
file system check. |
| 127 |
.TP |
| 128 |
.BI \-B " blocksize" |
| 129 |
Normally, |
| 130 |
.B e2fsck |
| 131 |
will search for the superblock at various different |
| 132 |
block sizes in an attempt to find the appropriate block size. |
| 133 |
This search can be fooled in some cases. This option forces |
| 134 |
.B e2fsck |
| 135 |
to only try locating the superblock at a particular blocksize. |
| 136 |
If the superblock is not found, |
| 137 |
.B e2fsck |
| 138 |
will terminate with a fatal error. |
| 139 |
.TP |
| 140 |
.B \-c |
| 141 |
This option causes |
| 142 |
.B e2fsck |
| 143 |
to use |
| 144 |
.BR badblocks (8) |
| 145 |
program to do a read-only scan of the device in order to find any bad |
| 146 |
blocks. If any bad blocks are found, they are added to the bad block |
| 147 |
inode to prevent them from being allocated to a file or directory. If |
| 148 |
this option is specified twice, then the bad block scan will be done |
| 149 |
using a non-destructive read-write test. |
| 150 |
.TP |
| 151 |
.BI \-C " fd" |
| 152 |
This option causes |
| 153 |
.B e2fsck |
| 154 |
to write completion information to the specified file descriptor |
| 155 |
so that the progress of the file system |
| 156 |
check can be monitored. This option is typically used by programs |
| 157 |
which are running |
| 158 |
.BR e2fsck . |
| 159 |
If the file descriptor number is negative, then absolute value of |
| 160 |
the file descriptor will be used, and the progress information will be |
| 161 |
suppressed initially. It can later be enabled by sending the |
| 162 |
.B e2fsck |
| 163 |
process a SIGUSR1 signal. |
| 164 |
If the file descriptor specified is 0, |
| 165 |
.B e2fsck |
| 166 |
will print a completion bar as it goes about its business. This requires |
| 167 |
that e2fsck is running on a video console or terminal. |
| 168 |
.TP |
| 169 |
.B \-d |
| 170 |
Print debugging output (useless unless you are debugging |
| 171 |
.BR e2fsck ). |
| 172 |
.TP |
| 173 |
.B \-D |
| 174 |
Optimize directories in file system. This option causes e2fsck to |
| 175 |
try to optimize all directories, either by re-indexing them if the |
| 176 |
file system supports directory indexing, or by sorting and compressing |
| 177 |
directories for smaller directories, or for file systems using |
| 178 |
traditional linear directories. |
| 179 |
.IP |
| 180 |
Even without the |
| 181 |
.B \-D |
| 182 |
option, |
| 183 |
.B e2fsck |
| 184 |
may sometimes optimize a few directories --- for example, if |
| 185 |
directory indexing is enabled and a directory is not indexed and would |
| 186 |
benefit from being indexed, or if the index structures are corrupted |
| 187 |
and need to be rebuilt. The |
| 188 |
.B \-D |
| 189 |
option forces all directories in the file system to be optimized. This can |
| 190 |
sometimes make them a little smaller and slightly faster to search, but |
| 191 |
in practice, you should rarely need to use this option. |
| 192 |
.IP |
| 193 |
The |
| 194 |
.B \-D |
| 195 |
option will detect directory entries with duplicate names in a single |
| 196 |
directory, which e2fsck normally does not enforce for performance reasons. |
| 197 |
.TP |
| 198 |
.BI \-E " extended_options" |
| 199 |
Set e2fsck extended options. Extended options are comma |
| 200 |
separated, and may take an argument using the equals ('=') sign. The |
| 201 |
following options are supported: |
| 202 |
.RS 1.2i |
| 203 |
.TP |
| 204 |
.BI ea_ver= extended_attribute_version |
| 205 |
Set the version of the extended attribute blocks which |
| 206 |
.B e2fsck |
| 207 |
will require while checking the file system. The version number may |
| 208 |
be 1 or 2. The default extended attribute version format is 2. |
| 209 |
.TP |
| 210 |
.B journal_only |
| 211 |
Only replay the journal if required, but do not perform any further checks |
| 212 |
or repairs. |
| 213 |
.TP |
| 214 |
.B fragcheck |
| 215 |
During pass 1, print a detailed report of any discontiguous blocks for |
| 216 |
files in the file system. |
| 217 |
.TP |
| 218 |
.B discard |
| 219 |
Attempt to discard free blocks and unused inode blocks after the full |
| 220 |
file system check (discarding blocks is useful on solid state devices and sparse |
| 221 |
/ thin-provisioned storage). |
| 222 |
Note that discard is done in pass 5 AFTER the |
| 223 |
file system has been fully checked and only if it does not contain recognizable |
| 224 |
errors. |
| 225 |
However there might be cases where |
| 226 |
.B e2fsck |
| 227 |
does not fully recognize a problem and hence in this case this |
| 228 |
option may prevent you from further manual data recovery. |
| 229 |
.TP |
| 230 |
.B nodiscard |
| 231 |
Do not attempt to discard free blocks and unused inode blocks. |
| 232 |
This option is exactly the opposite of discard option. |
| 233 |
This is set as default. |
| 234 |
.TP |
| 235 |
.B no_optimize_extents |
| 236 |
Do not offer to optimize the extent tree by eliminating unnecessary |
| 237 |
width or depth. This can also be enabled in the options section of |
| 238 |
.BR /etc/e2fsck.conf . |
| 239 |
.TP |
| 240 |
.B optimize_extents |
| 241 |
Offer to optimize the extent tree by eliminating unnecessary |
| 242 |
width or depth. This is the default unless otherwise specified in |
| 243 |
.BR /etc/e2fsck.conf . |
| 244 |
.TP |
| 245 |
.B inode_count_fullmap |
| 246 |
Trade off using memory for speed when checking a file system with a |
| 247 |
large number of hard-linked files. The amount of memory required is |
| 248 |
proportional to the number of inodes in the file system. For large file |
| 249 |
systems, this can be gigabytes of memory. (For example, a 40\ TB file system |
| 250 |
with 2.8 billion inodes will consume an additional 5.7 GB memory if this |
| 251 |
optimization is enabled.) This optimization can also be enabled in the |
| 252 |
options section of |
| 253 |
.BR /etc/e2fsck.conf . |
| 254 |
.TP |
| 255 |
.B no_inode_count_fullmap |
| 256 |
Disable the |
| 257 |
.B inode_count_fullmap |
| 258 |
optimization. This is the default unless otherwise specified in |
| 259 |
.BR /etc/e2fsck.conf . |
| 260 |
.TP |
| 261 |
.B readahead_kb |
| 262 |
Use this many KiB of memory to pre-fetch metadata in the hopes of reducing |
| 263 |
e2fsck runtime. By default, this is set to the size of two block groups' inode |
| 264 |
tables (typically 4\ MiB on a regular ext4 file system); if this amount is more |
| 265 |
than 1/50th of total physical memory, readahead is disabled. Set this to zero |
| 266 |
to disable readahead entirely. |
| 267 |
.TP |
| 268 |
.B bmap2extent |
| 269 |
Convert block-mapped files to extent-mapped files. |
| 270 |
.TP |
| 271 |
.B fixes_only |
| 272 |
Only fix damaged metadata; do not optimize htree directories or compress |
| 273 |
extent trees. This option is incompatible with the \-D and \-E bmap2extent |
| 274 |
options. |
| 275 |
.TP |
| 276 |
.B check_encoding |
| 277 |
Force verification of encoded filenames in case-insensitive directories. |
| 278 |
This is the default mode if the file system has the strict flag enabled. |
| 279 |
.TP |
| 280 |
.B unshare_blocks |
| 281 |
If the file system has shared blocks, with the shared blocks read-only feature |
| 282 |
enabled, then this will unshare all shared blocks and unset the read-only |
| 283 |
feature bit. |
| 284 |
If there is not enough free space then the operation will fail. |
| 285 |
If the file system does not have the read-only feature bit, but has shared |
| 286 |
blocks anyway, then this option will have no effect. |
| 287 |
Note when using this |
| 288 |
option, if there is no free space to clone blocks, there is no prompt to |
| 289 |
delete files and instead the operation will fail. |
| 290 |
.IP |
| 291 |
Note that unshare_blocks implies the "\-f" option to ensure that all passes |
| 292 |
are run. |
| 293 |
Additionally, if "\-n" is also specified, e2fsck will simulate trying |
| 294 |
to allocate enough space to deduplicate. |
| 295 |
If this fails, the exit code will be non-zero. |
| 296 |
.RE |
| 297 |
.TP |
| 298 |
.B \-f |
| 299 |
Force checking even if the file system seems clean. |
| 300 |
.TP |
| 301 |
.B \-F |
| 302 |
Flush the file system device's buffer caches before beginning. Only |
| 303 |
really useful for doing |
| 304 |
.B e2fsck |
| 305 |
time trials. |
| 306 |
.TP |
| 307 |
.BI \-j " external-journal" |
| 308 |
Set the pathname where the external-journal for this file system can be |
| 309 |
found. |
| 310 |
.TP |
| 311 |
.B \-k |
| 312 |
When combined with the |
| 313 |
.B \-c |
| 314 |
option, any existing bad blocks in the bad blocks list are preserved, |
| 315 |
and any new bad blocks found by running |
| 316 |
.BR badblocks (8) |
| 317 |
will be added to the existing bad blocks list. |
| 318 |
.TP |
| 319 |
.BI \-l " filename" |
| 320 |
Add the block numbers listed in the file specified by |
| 321 |
.I filename |
| 322 |
to the list of bad blocks. The format of this file is the same as the |
| 323 |
one generated by the |
| 324 |
.BR badblocks (8) |
| 325 |
program. Note that the block numbers are based on the blocksize |
| 326 |
of the file system. Hence, |
| 327 |
.BR badblocks (8) |
| 328 |
must be given the blocksize of the file system in order to obtain correct |
| 329 |
results. As a result, it is much simpler and safer to use the |
| 330 |
.B \-c |
| 331 |
option to |
| 332 |
.BR e2fsck , |
| 333 |
since it will assure that the correct parameters are passed to the |
| 334 |
.B badblocks |
| 335 |
program. |
| 336 |
.TP |
| 337 |
.BI \-L " filename" |
| 338 |
Set the bad blocks list to be the list of blocks specified by |
| 339 |
.IR filename . |
| 340 |
(This option is the same as the |
| 341 |
.B \-l |
| 342 |
option, except the bad blocks list is cleared before the blocks listed |
| 343 |
in the file are added to the bad blocks list.) |
| 344 |
.TP |
| 345 |
.B \-n |
| 346 |
Open the file system read-only, and assume an answer of `no' to all |
| 347 |
questions. Allows |
| 348 |
.B e2fsck |
| 349 |
to be used non-interactively. This option |
| 350 |
may not be specified at the same time as the |
| 351 |
.B \-p |
| 352 |
or |
| 353 |
.B \-y |
| 354 |
options. |
| 355 |
.TP |
| 356 |
.B \-p |
| 357 |
Automatically repair ("preen") the file system. This option will cause |
| 358 |
.B e2fsck |
| 359 |
to automatically |
| 360 |
fix any file system problems that can be safely fixed without human |
| 361 |
intervention. If |
| 362 |
.B e2fsck |
| 363 |
discovers a problem which may require the system administrator |
| 364 |
to take additional corrective action, |
| 365 |
.B e2fsck |
| 366 |
will print a description of the problem and then exit with the value 4 |
| 367 |
logically or'ed into the exit code. (See the \fBEXIT CODE\fR section.) |
| 368 |
This option is normally used by the system's boot scripts. It may not |
| 369 |
be specified at the same time as the |
| 370 |
.B \-n |
| 371 |
or |
| 372 |
.B \-y |
| 373 |
options. |
| 374 |
.TP |
| 375 |
.B \-r |
| 376 |
This option does nothing at all; it is provided only for backwards |
| 377 |
compatibility. |
| 378 |
.TP |
| 379 |
.B \-t |
| 380 |
Print timing statistics for |
| 381 |
.BR e2fsck . |
| 382 |
If this option is used twice, additional timing statistics are printed |
| 383 |
on a pass by pass basis. |
| 384 |
.TP |
| 385 |
.B \-v |
| 386 |
Verbose mode. |
| 387 |
.TP |
| 388 |
.B \-V |
| 389 |
Print version information and exit. |
| 390 |
.TP |
| 391 |
.B \-y |
| 392 |
Assume an answer of `yes' to all questions; allows |
| 393 |
.B e2fsck |
| 394 |
to be used non-interactively. This option |
| 395 |
may not be specified at the same time as the |
| 396 |
.B \-n |
| 397 |
or |
| 398 |
.B \-p |
| 399 |
options. |
| 400 |
.TP |
| 401 |
.BI \-z " undo_file" |
| 402 |
Before overwriting a file system block, write the old contents of the block to |
| 403 |
an undo file. This undo file can be used with |
| 404 |
.BR e2undo (8) |
| 405 |
to restore the old |
| 406 |
contents of the file system should something go wrong. If the empty string is |
| 407 |
passed as the undo_file argument, the undo file will be written to a file named |
| 408 |
e2fsck-\fIdevice\fR.e2undo in the directory specified via the |
| 409 |
\fIE2FSPROGS_UNDO_DIR\fR environment variable. |
| 410 |
|
| 411 |
WARNING: The undo file cannot be used to recover from a power or system crash. |
| 412 |
.SH EXIT CODE |
| 413 |
The exit code returned by |
| 414 |
.B e2fsck |
| 415 |
is the sum of the following conditions: |
| 416 |
.br |
| 417 |
0 \-\ No errors |
| 418 |
.br |
| 419 |
1 \-\ File system errors corrected |
| 420 |
.br |
| 421 |
2 \-\ File system errors corrected, system should |
| 422 |
.br |
| 423 |
\ \ be rebooted |
| 424 |
.br |
| 425 |
4 \-\ File system errors left uncorrected |
| 426 |
.br |
| 427 |
8 \-\ Operational error |
| 428 |
.br |
| 429 |
16 \-\ Usage or syntax error |
| 430 |
.br |
| 431 |
32 \-\ E2fsck canceled by user request |
| 432 |
.br |
| 433 |
128 \-\ Shared library error |
| 434 |
.SH SIGNALS |
| 435 |
The following signals have the following effect when sent to |
| 436 |
.BR e2fsck . |
| 437 |
.TP |
| 438 |
.B SIGUSR1 |
| 439 |
This signal causes |
| 440 |
.B e2fsck |
| 441 |
to start displaying a completion bar or emitting progress information. |
| 442 |
(See discussion of the |
| 443 |
.B \-C |
| 444 |
option.) |
| 445 |
.TP |
| 446 |
.B SIGUSR2 |
| 447 |
This signal causes |
| 448 |
.B e2fsck |
| 449 |
to stop displaying a completion bar or emitting progress information. |
| 450 |
.SH REPORTING BUGS |
| 451 |
Almost any piece of software will have bugs. If you manage to find a |
| 452 |
file system which causes |
| 453 |
.B e2fsck |
| 454 |
to crash, or which |
| 455 |
.B e2fsck |
| 456 |
is unable to repair, please report it to the author. |
| 457 |
.PP |
| 458 |
Please include as much information as possible in your bug report. |
| 459 |
Ideally, include a complete transcript of the |
| 460 |
.B e2fsck |
| 461 |
run, so I can see exactly what error messages are displayed. (Make sure |
| 462 |
the messages printed by |
| 463 |
.B e2fsck |
| 464 |
are in English; if your system has been |
| 465 |
configured so that |
| 466 |
.BR e2fsck 's |
| 467 |
messages have been translated into another language, please set the |
| 468 |
.B LC_ALL |
| 469 |
environment variable to |
| 470 |
.B C |
| 471 |
so that the transcript of e2fsck's output will be useful to me.) |
| 472 |
If you |
| 473 |
have a writable file system where the transcript can be stored, the |
| 474 |
.BR script (1) |
| 475 |
program is a handy way to save the output of |
| 476 |
.B e2fsck |
| 477 |
to a file. |
| 478 |
.PP |
| 479 |
It is also useful to send the output of |
| 480 |
.BR dumpe2fs (8). |
| 481 |
If a specific inode or inodes seems to be giving |
| 482 |
.B e2fsck |
| 483 |
trouble, try running the |
| 484 |
.BR debugfs (8) |
| 485 |
command and send the output of the |
| 486 |
.BR stat (1u) |
| 487 |
command run on the relevant inode(s). If the inode is a directory, the |
| 488 |
.B debugfs |
| 489 |
.I dump |
| 490 |
command will allow you to extract the contents of the directory inode, |
| 491 |
which can sent to me after being first run through |
| 492 |
.BR uuencode (1). |
| 493 |
The most useful data you can send to help reproduce |
| 494 |
the bug is a compressed raw image dump of the file system, generated using |
| 495 |
.BR e2image (8). |
| 496 |
See the |
| 497 |
.BR e2image (8) |
| 498 |
man page for more details. |
| 499 |
.PP |
| 500 |
Always include the full version string which |
| 501 |
.B e2fsck |
| 502 |
displays when it is run, so I know which version you are running. |
| 503 |
.SH ENVIRONMENT |
| 504 |
.TP |
| 505 |
.B E2FSCK_CONFIG |
| 506 |
Determines the location of the configuration file (see |
| 507 |
.BR e2fsck.conf (5)). |
| 508 |
.SH AUTHOR |
| 509 |
This version of |
| 510 |
.B e2fsck |
| 511 |
was written by Theodore Ts'o <[email protected]>. |
| 512 |
.SH SEE ALSO |
| 513 |
.BR e2fsck.conf (5), |
| 514 |
.BR badblocks (8), |
| 515 |
.BR dumpe2fs (8), |
| 516 |
.BR debugfs (8), |
| 517 |
.BR e2image (8), |
| 518 |
.BR mke2fs (8), |
| 519 |
.BR tune2fs (8) |