E2FSCK(8)
๐ธ E2FSCK(8) ๐ธ โ the System Manager's Manual page, but make it make sense
okay bestie, gather round ๐ you're reading e2fsck, section 8 of the manual, and I'm gonna walk you through it like we're texting at 2am. no cap, every single detail is staying in here.
โจ NAME โจ
e2fsck โ check a Linux ext2/ext3/ext4 file system ๐ฆ
โจ SYNOPSIS โจ
e2fsck [ -pacnyrdfkvtDFV ] [ -b superblock ] [ -B blocksize ] [ -l|-L
bad_blocks_file ] [ -C fd ] [ -j external-journal ] [ -E
extended_options ] [ -z undo_file ] device
โจ DESCRIPTION โจ
so e2fsck is the girl who checks up on the ext2/ext3/ext4 family of file systems. that's her whole job. ๐
for ext3 and ext4 file systems that use a journal โ if the system got shut down uncleanly but with no errors, then normally, after replaying the committed transactions in the journal, the file system should be marked as clean. so basically, for file systems that use journaling, e2fsck will normally just replay the journal and dip out โ unless its superblock is like "hmm actually we need more checking." ๐
device is a block device (e.g., /dev/sdc1) or a file containing the file system.
โ ๏ธ okay this part is IMPORTANT, like genuinely. in general it is not safe to rune2fsckon mounted file systems. the only exception is if the-noption is specified, and-c,-l, or-Loptions are not specified. but even if it is safe to do so, the results printed bye2fsckare not valid if the file system is mounted. ife2fsckasks whether or not you should check a file system which is mounted, the only correct answer is ``no''. only experts who really know what they're doing should even consider answering that question any other way. like, i'm not joking. ๐ซถ
if e2fsck is run in interactive mode (meaning that none of -y, -n, or -p are specified), the program will ask the user to fix each problem found in the file system. here's the vibe check on the responses:
- a response of
'y'will fix the error ๐ฉน 'n'will leave the error unfixed ๐'a'will fix the problem and all subsequent problems ๐
and pressing Enter will proceed with the default response, which is printed before the question mark. pressing Control-C terminates e2fsck immediately. ๐
โจ OPTIONS โจ
-aโ this option does the same thing as the-poption. it's provided for backwards compatibility only; it is suggested that people use the-poption whenever possible. she's legacy, she's nostalgic, she's fine ๐ธ-bsuperblock โ instead of using the normal superblock, use an alternative superblock specified by superblock. this option is normally used when the primary superblock has been corrupted. ๐ญ the location of backup superblocks is dependent on the file system's blocksize, the number of blocks per group, and features such assparse_super.
additional backup superblocks can be determined by using the mke2fs program using the -n option to print out where the superblocks exist, supposing mke2fs is supplied with arguments that are consistent with the file system's layout (e.g. blocksize, blocks per group, sparse_super, etc.).
if an alternative superblock is specified and the file system is not opened read-only, e2fsck will make sure that the primary superblock is updated appropriately upon completion of the file system check. โจ
-Bblocksize โ normally,e2fsckwill search for the superblock at various different block sizes in an attempt to find the appropriate block size. this search can be fooled in some cases ๐. this option forcese2fsckto only try locating the superblock at a particular blocksize. if the superblock is not found,e2fsckwill terminate with a fatal error. ๐-cโ this option causese2fsckto use thebadblocks(8)program to do a read-only scan of the device in order to find any bad blocks. if any bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a file or directory. and if this option is specified twice, then the bad block scan will be done using a non-destructive read-write test. ๐ฅ-Cfd โ this option causese2fsckto write completion information to the specified file descriptor so that the progress of the file system check can be monitored. this option is typically used by programs which are runninge2fsck. if the file descriptor number is negative, then the absolute value of the file descriptor will be used, and the progress information will be suppressed initially โ it can later be enabled by sending thee2fsckprocess aSIGUSR1signal. if the file descriptor specified is0,e2fsckwill print a completion bar as it goes about its business. this requires thate2fsckis running on a video console or terminal. ๐-dโ print debugging output (useless unless you are debugginge2fsck). ๐ literally useless for the rest of us-Dโ optimize directories in file system. this option causese2fsckto try to optimize all directories, either by re-indexing them if the file system supports directory indexing, or by sorting and compressing directories for smaller directories, or for file systems using traditional linear directories.
even without the -D option, e2fsck may sometimes optimize a few directories --- for example, if directory indexing is enabled and a directory is not indexed and would benefit from being indexed, or if the index structures are corrupted and need to be rebuilt. the -D option forces all directories in the file system to be optimized. this can sometimes make them a little smaller and slightly faster to search, but in practice, you should rarely need to use this option. ngl, lowkey optional ๐
the -D option will detect directory entries with duplicate names in a single directory, which e2fsck normally does not enforce for performance reasons. ๐
-Eextended_options โ sete2fsckextended options. extended options are comma separated, and may take an argument using the equals ('=') sign. the following options are supported:ea_ver=extended_attribute_versionโ set the version of the extended attribute blocks whiche2fsckwill require while checking the file system. the version number may be1or2. the default extended attribute version format is2. โจjournal_onlyโ only replay the journal if required, but do not perform any further checks or repairs.fragcheckโ during pass 1, print a detailed report of any discontiguous blocks for files in the file system. ๐งdiscardโ attempt to discard free blocks and unused inode blocks after the full file system check (discarding blocks is useful on solid state devices and sparse / thin-provisioned storage). note that discard is done in pass 5 AFTER the file system has been fully checked and only if it does not contain recognizable errors. however there might be cases wheree2fsckdoes not fully recognize a problem and hence in this case this option may prevent you from further manual data recovery. โ ๏ธ be careful with this one bestienodiscardโ do not attempt to discard free blocks and unused inode blocks. this option is exactly the opposite of thediscardoption. this is set as default.no_optimize_extentsโ do not offer to optimize the extent tree by eliminating unnecessary width or depth. this can also be enabled in the options section of/etc/e2fsck.conf.optimize_extentsโ offer to optimize the extent tree by eliminating unnecessary width or depth. this is the default unless otherwise specified in/etc/e2fsck.conf.inode_count_fullmapโ trade off using memory for speed when checking a file system with a large number of hard-linked files. the amount of memory required is proportional to the number of inodes in the file system. for large file systems, this can be gigabytes of memory. (for example, a 40 TB file system with 2.8 billion inodes will consume an additional 5.7 GB memory if this optimization is enabled.) this optimization can also be enabled in the options section of/etc/e2fsck.conf. ๐ญ the way that's so much memoryno_inode_count_fullmapโ disable theinode_count_fullmapoptimization. this is the default unless otherwise specified in/etc/e2fsck.conf.readahead_kbโ use this many KiB of memory to pre-fetch metadata in the hopes of reducinge2fsckruntime. by default, this is set to the size of two block groups' inode tables (typically 4 MiB on a regular ext4 file system); if this amount is more than 1/50th of total physical memory, readahead is disabled. set this to zero to disable readahead entirely. ๐โ๏ธbmap2extentโ convert block-mapped files to extent-mapped files. ๐fixes_onlyโ only fix damaged metadata; do not optimize htree directories or compress extent trees. this option is incompatible with the-Dand-E bmap2extentoptions. ๐ซcheck_encodingโ force verification of encoded filenames in case-insensitive directories. this is the default mode if the file system has the strict flag enabled.unshare_blocksโ if the file system has shared blocks, with the shared blocks read-only feature enabled, then this will unshare all shared blocks and unset the read-only feature bit. if there is not enough free space then the operation will fail. if the file system does not have the read-only feature bit, but has shared blocks anyway, then this option will have no effect. note when using this option, if there is no free space to clone blocks, there is no prompt to delete files and instead the operation will fail. ๐
more of this page is coming bestie, don't go anywhere ๐
okay so quick lil note before we move on โ unshare_blocks implies the -f option, so all the passes actually run. no skipping, bestie. ๐ซถ and if you also throw in -n, e2fsck will simulate trying to allocate enough space to deduplicate. if that lil simulation fails? the exit code goes non-zero. that's it, that's the tea. ๐
-fโ force the check even if the file system looks all clean and innocent. don't trust the vibes, verify โจ-Fโ flush the file system device's buffer caches before starting. ngl this is only really useful for doinge2fscktime trials (it's a benchmarking queen, not an everyday icon).-jexternal-journal โ sets the pathname where the external-journal for this file system lives. point her at the right spot and she'll find it. ๐-kโ when you pair this with the-coption, any existing bad blocks in the bad blocks list get preserved, and any new bad blocks found by runningbadblocks(8)get added on top of that existing list. hoarding the bad blocks, honestly iconic.-lfilename โ adds the block numbers listed in the file named filename to the list of bad blocks. the format of this file is the same as the onebadblocks(8)spits out. heads up though: the block numbers are based on the blocksize of the file system, sobadblocks(8)must be given the file system's blocksize or your results are gonna be wrong. which is exactly why it's much simpler and safer to just use the-coption one2fsckinstead โ she'll make sure the correct parameters get passed to the badblocks program for you. let her cook. ๐ฅ-Lfilename โ sets the bad blocks list to be the list of blocks specified by filename. (this is the same as the-loption, EXCEPT the bad blocks list gets cleared before the blocks in the file are added. out with the old, in with the new, periodt.)-nโ opens the file system read-only and assumes an answer ofnoto literally every question. this letse2fsckbe used non-interactively. โ ๏ธ may not be specified at the same time as the-por-yoptions. pick a lane bestie, she can't do both.-pโ automatically repair ("preen") the file system. this makese2fsckauto-fix any file system problems that can be safely fixed without a human in the mix. ๐ง if she hits a problem that might need the system administrator to take extra corrective action, she'll print a description of the problem and then exit with the value4logically or'ed into the exit code. (peep the EXIT CODE section for that whole situation.) this one is normally used by the system's boot scripts. โ ๏ธ may not be specified at the same time as the-nor-yoptions.-rโ this option does absolutely nothing at all. it's here purely for backwards compatibility. a decorative little ghost. ๐ป-tโ print timing statistics fore2fsck. and if you use this option twice, you get extra timing statistics printed on a pass-by-pass basis. the more you know ๐-vโ verbose mode. she's gonna talk a LOT. ๐ฌ-Vโ print version information and exit. quick lil flex of what she's running.-yโ assume an answer ofyesto every single question; letse2fsckbe used non-interactively. (the yes-girl of the group chat, truly saying yes to everything ๐) โ ๏ธ may not be specified at the same time as the-nor-poptions.-zundo_file โ before overwriting a file system block, write the old contents of that block to an undo file. this undo file can then be used withe2undo(8)to restore the old contents of the file system if something goes wrong. ๐ if the empty string is passed as the undo_file argument, the undo file gets written to a file namede2fsck-device.e2undoin the directory specified via theE2FSPROGS_UNDO_DIRenvironment variable.
WARNING: The undo file cannot be used to recover from a power or system crash. it's a safety net for oopsies, not for the entire grid going down, okay? know the limits. ๐ญ
๐ฅ EXIT CODE ๐ฅ
the exit code e2fsck returns is the sum of the following conditions:
0 - No errors
1 - File system errors corrected
2 - File system errors corrected, system should
be rebooted
4 - File system errors left uncorrected
8 - Operational error
16 - Usage or syntax error
32 - E2fsck canceled by user request
128 - Shared library error
slay, math checks out, go read your number. โจ
๐ก SIGNALS ๐ก
here's what happens when you send these signals to e2fsck:
SIGUSR1
this signal makes e2fsck start displaying a completion bar or emitting progress information. (go look at the discussion of the -C option for the full lore.) ๐ถ
SIGUSR2
this signal makes e2fsck stop displaying a completion bar or emitting progress information. okay she's done performing, everyone go home. ๐ฌ
๐ REPORTING BUGS ๐
almost any piece of software is gonna have bugs, that's just the reality of it. if you manage to find a file system that makes e2fsck crash, or one that e2fsck is unable to repair, please report it to the author. you're doing a public service bestie ๐ซถ
please include as much information as possible in your bug report. ideally, include a complete transcript of the e2fsck run, so I can see exactly what error messages are displayed. (make sure the messages printed by e2fsck are in English โ if your system has been configured so that e2fsck's messages have been translated into another language, please set the LC_ALL environment variable to C so that the transcript of e2fsck's output will actually be useful to me.) if you have a writable file system where the transcript can be stored, the script(1) program is a handy way to save the output of e2fsck to a file. ๐
it is also useful to send the output of dumpe2fs(8). if a specific inode or inodes seems to be giving e2fsck trouble, try running the debugfs(8) command and send the output of the stat(1u) command run on the relevant inode(s). if the inode is a directory, the debugfs dump command will let you extract the contents of the directory inode, which can be sent to me after being first run through uuencode(1). the most useful data you can send to help reproduce the bug is a compressed raw image dump of the file system, generated using e2image(8). peep the e2image(8) man page for more details. ๐
always include the full version string which e2fsck displays when it is run, so I know which version you are running. ๐
๐ฑ ENVIRONMENT ๐ฑ
E2FSCK_CONFIG
determines the location of the configuration file (see e2fsck.conf(5)). ๐
โ๏ธ AUTHOR โ๏ธ
this version of e2fsck was written by Theodore Ts'o <tytso@mit.edu>. king behavior, honestly ๐
๐ SEE ALSO ๐
e2fsck.conf(5), badblocks(8), dumpe2fs(8), debugfs(8), e2image(8), mke2fs(8), tune2fs(8)
and that's the whole page, bestie!! ๐ this was E2fsprogs version 1.47.4, dated March 2025 โ and if you're a proper nerd you'd find it filed under E2FSCK(8). go forth and fsck responsibly ๐
๐
๐ฆ where this page comes from
- ubuntu stonking: e2fsck-static 1.47.4-1 ยท GPL-2.0-only
- Copyright 1993, 1994, 1995 by Theodore Ts'o. All Rights Reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms