Be notified before every regular fsck
Tagged:  •    •    •  

All Linux users have experienced this so far: you boot you computer or laptop just to do something quickly, and then the fsck kicks in and scans your partitions. A process which can take several minutes.

That's not necessarily a bad thing, it just needs to be done to keep your file system consistent. But it would be nice if you'd be notified in advance that upon the next boot, your partition(s) will be scanned.

I wrote a tiny script to make that happen, using the tune2fs output. It's in the e2fsprogs package. Make sure you have a MTA installed on your system, like Postfix. For that particular MTA I wrote in one of my previous entries how to install that. But any other MTA would suffice as well.

Download the script and put it somewhere safe. Change the partitions and email address as you want them.

Then, make sure to call this script each time you boot your system. Many distributions have a 'local' script in their boot process to call custom scripts. Every distro chooses a different place for this script. Many distributions, like Arch Linux and Ubuntu, use /etc/rc.local. Gentoo Linux uses a different location: /etc/conf.d/local.start. When in doubt, consult the distribution's documentation.

Now, add the following line to the local boot script:

/path/to/script/fsckck &

Be alerted for possible exit calls. Ubuntu has one by default in their boot script, so make sure that exit is called last, or remove the line altogether.

Now, everytime your system will mention that upon the next boot, your file system will be fsck