Thursday, February 4, 2010

Force FSCK on Reboot

SkyHi @ Thursday, February 04, 2010

Scenario / Question:

How do I force a fsck on the file system

Solution / Answer:

To force fsck that is used to check and repair Linux file systems. Fsck should always be run on unmounted file system. By invoking fsck while the system is starting or booting like on a reboot, you can ensure that all file systems are unmounted. To do this create a file in the “/” directory called “forcefsck”.

Force fsck on a boot using /forcefsck

On boot linux looks for a file called “forcefsck” in the root “/” directory. If this file exists then the system will invoke a full file system check on boot.
To create the file you first need to be the root user:
$ su -
Create a the file forcefsck in the root directory:
# touch /forcefsck
Reboot the system:
# shutdown -r now