Linux e2fsck Command
The Linux e2fsck command is used to check whether the partition using the Linux ext2 file system is working properly.
Syntax
e2fsck [-pacnydfvFV] [-b superblock] [-B blocksize] [-l|-L bad_blocks_file] [-C fd] device
Parameter Description:
- device: The hard disk partition to be checked, e.g., /dev/sda1
- -a: Check the partition and automatically repair if there are problems, equivalent to the functionality of -p.
- -b: Set the location where the superblock is stored.
- -B: Set the size of the unit block.
- -c: Check whether the partition has bad tracks.
- -C file: Save the check results to file for viewing.
- -d: Print e2fsck's debug results.
- -f: Force check.
- -F: Clear the device's buffer cache before starting the check to avoid errors.
- -l bad_blocks_file: Add the block data with bad tracks to bad_blocks_file.
- -L bad_blocks_file: Store the bad track block data in bad_blocks_file; if the file does not exist, it is automatically created.
- -n: Open the file system in read-only mode.
- -p: Check the partition and automatically repair if there are problems.
- -v: Verbose display mode.
- -V: Display the current version of e2fsck.
- -y: Preset all questions during the check to answer "yes".
Examples
Check whether /dev/hda5 is normal. If there are any abnormalities, repair automatically, and set all prompts to answer "yes":
e2fsck -a -y /dev/hda5
Note:
In most cases where e2fsck is used to check a hard disk partition, the situation is usually special. Therefore, it is best to umount the partition first, and then run e2fsck to perform the check. If you must check /, please enter single user mode before running it.
Other Extensions
Linux Command Reference