Linux e2fsck command
The Linux e2fsck command is used to check whether a 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 it if there are problems; equivalent to -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 sectors
- -C file : store the check results in file for viewing
- -d : print the debug results of e2fsck
- -f : force the check
- -F : before starting the check, clear the device's buffer cache to avoid errors
- -l bad_blocks_file : add data about blocks with bad sectors to bad_blocks_file
- -L bad_blocks_file : set the data of blocks with bad sectors to be stored in bad_blocks_file; if the file does not exist, it is created automatically
- -n : open the file system in [read-only] mode
- -p : check the partition and automatically repair it if there are problems
- -v : verbose display mode
- -V : display the current version of e2fsck
- -y : preset all questions during the check to be answered [yes]
Example
Check whether /dev/hda5 is normal; if there are errors, repair them automatically, and set all questions to be answered [yes]:
e2fsck -a -y /dev/hda5
**Note **:
In most cases, using e2fsck to check a hard disk partition involves special circumstances, so it is best to unmount the partition first and then run e2fsck to check it. If you must check /, enter single user mode before executing.
Linux Command Reference