fsck is a file system consistency check and interactive repair tool.
Here is a quick tip that will show how you can tell your Linux system to perform a fsck on its partitions on the next reboot. Normally this will happen by default, after some time as configured in the filesystem at creation time (or changed later): after a number of days or a number of filesystem mounts.
If for some reason, you want to force the system to run fsck on the next reboot just use one of the following options:
1. 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:
1 |
[[email protected]~]#su - |
Create a the file forcefsck in the root directory:
1 |
/forcefsck |
Reboot the system:
1 |
-r now |
During the first reboot the system will run fsck and after completing this it will also remove the /forcefsck file from the system.
2. Force fsck on a boot using shutdown command
The -F option force fsck on reboot, login as root and type the following command to reboot and run fsck:
1 |
-rF now |