Debian – How to force fsck at every boot – all (relevant) filesystems

debianfsck

I'm working with a fanless PC (hundreds of them, in fact) that has debian 6 and 3 partitions( FAT and 2x ext2). The system doesn't have a power button as such so most people tend to yank the plug to 'shut it down' rather than init 0 (or equivalent). As a result the filesystem(s) build up errors pretty rapidly.

I've tried using 'shutdown -rF' to force fsck but this doesn't seem to be working. I'm wondering if there is some way to tell the system to check each mount point / FS before they are mounted.

I've tried setting the fsck param in /etc/fstab. This typically gives me a 'Errors found. Run fsck manually' message.

Are there other options to try?

Best Answer

In /etc/init.d/checkfs.sh is the line if [ -f /forcefsck ] || grep -s -w -i "forcefsck" /proc/cmdline, so providing forcefsck on the kernel command line or generating a /forcefsck file on shutdown should cause an fsck on the next reboot.

To prevent manual fsck runs, ask fsck to try to automatically fix errors with the -y option by uncommenting and changing no to yes in the following /etc/default/rcS entry, after the edit it should look like:

# automatically repair filesystems with inconsistencies during boot
FSCKFIX=yes

One option (forcefsck or FSCKFIX) does not imply the other.

Related Question