System and processes
The e2fsck command
Checks and repairs ext2, ext3 and ext4 filesystems, ideally unmounted.
Most useful options
-pAutomatic repair: fixes without asking whatever can be safely fixed. It is the mode boot scripts use-nOpens the filesystem read-only and answers no to everything. It cannot be combined with -p or -y-yAnswers yes to all questions. It cannot be combined with -n or -p-fForces a full check even when the filesystem looks clean-b superbloqueUses a backup superblock instead of the primary one, for example when that one is damaged-tPrints timing statistics. If given twice, it also prints them per passCopy-ready examples
$ sudo e2fsck -n /dev/sda1only checks: opens the partition read-only and changes nothing.$ sudo umount /dev/sda1 && sudo e2fsck -f /dev/sda1unmounts the partition and forces a full check. Without -y, it asks before each repair.$ sudo e2fsck -p /dev/sda1repairs without asking whatever can be safely fixed. If something needs manual action, it describes it and exits with code 4.$ sudo e2fsck -b 32768 /dev/sda1uses a backup superblock, here 32768. The positions depend on the block size: mkfs.ext4 -n shows them with the same parameters.$ sudo e2fsck -y /dev/sda1warning: answers yes to everything and can modify the disk. Do it with a backup and the partition unmounted.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| /dev/sda1 is mounted. | The partition is mounted and e2fsck detects it. In an interactive terminal it warns of severe damage and asks whether to continue. Without an interactive terminal, or when the device is busy, it aborts. | Unmount it with sudo umount /dev/sda1 and run e2fsck again. |
| Cannot continue, aborting. | It appears after the mount warning when there is no interactive terminal, for example in a script, or when the device is busy. | Unmount the partition and run e2fsck from an interactive terminal. |
Typical mistakes
- With -n on a mounted partition, the warning is «Warning! ... is mounted.» and it checks read-only without asking for confirmation.
- e2fsck refuses to combine -p with -n or -y and answers «Only one of the options -p/-a, -n or -y may be specified.».
- With -y on a mounted partition, the mount question is not answered by -y: e2fsck asks it in the terminal.
- The position of the backup superblocks depends on the block size, according to the manual. Do not guess the number.
Differences from similar commands
FAQ
Do I need root?
In practice yes: you need read permission on the device and, to repair it, write permission.
What is a superblock?
It is the filesystem header, with its size, its blocks and the location of the backup copies. If it is damaged, -b lets you use a copy.
What does -f do if the filesystem looks clean?
It forces the full check even when the filesystem has no error flags.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course