
KB No. 2561: CHECKING THE FILE SYSTEM
This article describes the steps to follow to perform a file system check.
In Linux, thefsckcommand is used to check the consistency of the file system, and can be used to correct any inconsistencies it detects.
File system verification
Checking the read-only file system
The-noption opens the file system in read-only mode and answersno to all questions.

Check at next startup
- If you do not want to restart the server immediately but want to run a test the next time it starts up, you must create the forcefsck file in the server root directory.:~# touch /forcefsck
- Run the shutdown command with the -F option (force the use of fsck at startup).:~# shutdown -r -F now
File system repair
Startup repair
It is possible to havefsckautomatically repair all errors at startup by answeringyesto the questions.
To enable this option, edit the/etc/default/rcSfile and change the value ofFSCKFIXtoyes(the default value isno). This will cause the server to execute thefsck -ycommand (fsck yes…).
FSCKFIX=yes
Then run theshutdowncommand with the-Foption (forcefsckto run at startup):
:~# shutdown -r -F now
Repair in Maintenance mode
Once in maintenance mode (single-user mode), use themountcommand to ensure that the partition is not mounted before repairing it. Example:
:~#fsck -cyf /dev/sda2
- y: Answers "yes" to all questions, allowing non-interactive use of e2fsck.
- f: Forces verification even if the file system appears clean.
- c: This option forcese2fsckto run the program badblocks program to find bad sectors on the media hosting the file system. These sectors will then be marked as bad and added to the inode of bad blocks.
Don't forget to restart the server with the reboot command after the repair.
Validation
Once the repair is complete, you can (re)check the file system.