$linuxjunkies
>

e2fsck(8)

Check and repair ext2/ext3/ext4 filesystems for consistency errors.

UbuntuDebianFedoraArch

Synopsis

e2fsck [OPTIONS] device

Description

e2fsck is a filesystem consistency checker and interactive repair tool for ext2, ext3, and ext4 filesystems. It detects and fixes corrupted inodes, directory blocks, extent trees, and other filesystem metadata. Running e2fsck on a mounted filesystem is dangerous and typically prevented; repair work is best done on unmounted filesystems or during system boot.

The tool works in several passes: first scanning inodes, then examining directories and links, then checking directory connectivity, validating inode information, and finally checking group summary information. When errors are found, e2fsck prompts for repair authorization unless automatic repair mode is selected.

Common options

FlagWhat it does
-nRead-only mode; answer 'no' to all prompts without repairing anything
-yAutomatically answer 'yes' to all prompts; dangerous—use with caution
-pAutomatically repair filesystem; exit with error code if repair not possible
-fForce checking even if filesystem appears clean
-vVerbose output; print details of what is being checked
-CDisplay progress bar showing completion percentage
-j external_journalUse external journal file instead of journal in filesystem
-DOptimize directories (hash tree structures) during check
-b superblockUse alternate superblock (useful for corrupted primary superblock)
-B blocksizeSpecify blocksize (in bytes) for superblock and block reading

Examples

Read-only check of /dev/sda1 without making repairs; safe preview mode

sudo e2fsck -n /dev/sda1

Automatically repair /dev/sda1; typically used during boot if fsck is interrupted

sudo e2fsck -p /dev/sda1

Force a full check with verbose output, even if filesystem marked clean

sudo e2fsck -f -v /dev/sda1

Use alternate superblock at block 32768 when primary superblock is corrupted

sudo e2fsck -b 32768 /dev/sda1

Automatically repair with progress bar display; non-interactive mode

sudo e2fsck -C -y /dev/sda1

Check filesystem and optimize directory hash tree structures

sudo e2fsck -D /dev/sda1

Related commands