I think it's time to turn off automatic periodic ext3 fscks

April 18, 2010

I've noticed a pattern lately: I have a number of infrequently rebooted machines, and every time I reboot one of those machines I wind up sitting and drumming my fingers as the machine cheerfully announces 'filesystem X hasn't been checked in N days, checking for you'. It takes a while, because these filesystems are often kind of big and kind of full of things.

This is not ext3's fault; it is faithfully doing what it is configured to do, and even with all of the improvements you can stuff into it, fsck can only go so fast because your disks only go so fast. But, however much I don't like saying this, I think it means that it's time to stop having systems automatically do periodic ext3 fscks. When I reboot a machine under controlled circumstances, I almost always want it to come back up as soon as possible; I do not want to sit there for ten or twenty minutes as it grinds through a filesystem check. While I like the reassurance of periodic fscks of my filesystems, I don't like them quite that much.

There are two periodic checks that ext3 does, one based on how recently the filesystem was checked and one based on how many times it's been mounted. You can check the state of both of these with 'dumpe2fs -h'; the time based check is in the 'Last checked', 'Check interval', and 'Next check after' fields, and the mount count based check is in the 'Mount count' and 'Maximum mount count' fields.

(Checking is worthwhile, because some Linux distributions seem to turn off these checks by default; our Red Hat Enterprise Linux machines have both turned off, for example.)

Disabling either or both checks is done by tune2fs; 'tune2fs -c -1' (or 0) will turn off mount count based checks, and 'tune2fs -i 0' will disable the time based checks. The last time I tried to do anything with tune2fs, it had to be used on an unmounted filesystem, but that may have changed by now. So in summary (and for my future reference), you want to do:

tune2fs -c -1 -i 0 /dev/whatever

While it may sound alarming to turn off these automatic periodic checks, I should point out explicitly what my experience shows: these automatic checks are happening only very infrequently. If you only reboot machines once or twice a year (or even less frequently), you are only getting very infrequent checks from these 'periodic' checks. If filesystem corruption is a significant concern for you, you are better off explicitly scheduling and performing more frequent checks (or at least more predictable ones). That way you know that your filesystems have all been checked within, say, the last three months.

(I suppose the straightforward way to do this is to actually set a time based check interval and then reboot your machines at slightly more than that time interval, so you might set 85 days as the check interval and then reboot your machines every 90 days. My understanding is that the state of the art of doing this without reboots involves LVM, snapshots, and fsck'ing the snapshot to see if anything comes up, but I have not looked into this very much.)

Written on 18 April 2010.
« The 30 second elevator pitch on HTML 4.01 (vs XHTML)
Why you don't want to host your MTA machine in the cloud »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Sun Apr 18 01:33:08 2010
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.