e2fsck(8)
Check and repair ext2/ext3/ext4 filesystems for consistency errors.
Synopsis
e2fsck [OPTIONS] deviceDescription
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
| Flag | What it does |
|---|---|
-n | Read-only mode; answer 'no' to all prompts without repairing anything |
-y | Automatically answer 'yes' to all prompts; dangerous—use with caution |
-p | Automatically repair filesystem; exit with error code if repair not possible |
-f | Force checking even if filesystem appears clean |
-v | Verbose output; print details of what is being checked |
-C | Display progress bar showing completion percentage |
-j external_journal | Use external journal file instead of journal in filesystem |
-D | Optimize directories (hash tree structures) during check |
-b superblock | Use alternate superblock (useful for corrupted primary superblock) |
-B blocksize | Specify 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/sda1Automatically repair /dev/sda1; typically used during boot if fsck is interrupted
sudo e2fsck -p /dev/sda1Force a full check with verbose output, even if filesystem marked clean
sudo e2fsck -f -v /dev/sda1Use alternate superblock at block 32768 when primary superblock is corrupted
sudo e2fsck -b 32768 /dev/sda1Automatically repair with progress bar display; non-interactive mode
sudo e2fsck -C -y /dev/sda1Check filesystem and optimize directory hash tree structures
sudo e2fsck -D /dev/sda1