Sometimes it is necessary to force a filesystem check (fsck) on the next server reboot. Here are the different methods available.
Method 1: forcefsck
Create a file named forcefsck in the root directory:
touch /forcefsck
On the next reboot, an fsck will automatically be performed on all filesystems. The file is automatically deleted after the check.
Method 2: tune2fs
With tune2fs, you can reset the mount count to force a check:
tune2fs -C 100 /dev/sda1
Method 3: shutdown with -F
The -F parameter with the shutdown command forces an fsck on the next boot:
shutdown -rF now
Important Notes
- An fsck on large filesystems can take several minutes to hours
- The server is unreachable during the check
- Never run fsck on a mounted filesystem
- Always create a backup before forcing an fsck
If you have questions about filesystem maintenance, contact info@ingate.de.