...and how do I find out?
Say I am about to reboot a server. I would like to minimize downtime, so thinking about wrapping reboot in an alias that says "hang on buddy, you're going to hit a fsck on boot".
Next question.. what's the best way to say "lets do it next time?" set the last check date?
I know tune2fs can set a bunch of parameters, but how would I get em?
If all you want to do is avoid an fsck, adding the -f option to shutdown should help with that. shutdown -F to force fsck.
tune2fs -l /dev/foo
will tell you the interesting bits of information.Here's a start at extracting just what you need:
If the "Next check after" date is in the past, there will be an fsck.
If the filesystem state is not clean, there will be an fsck. (this could also happen if there's a problem with the system during reboot/shutdown that prevents a clean unmount)
If the mount count has reached the maximum mount count, there will be an fsck.
Using
tune2fs -l /path/to/device
:-c
to change the max or-C
to change the count-i
to change the interval or-T
to change the last checkedthe other option is you can manually make it skip fsck checks at boot by updating the 6th field in your /etc/fstab:
This is the similar to what most fstabs will have 1 means that it should be checked and is a root file system, 2 means it should be checked but will be done in parallel with other file systems and 0 means skip checking
this is also true no matter the file system
If you don't want to guess - do this:
touch /fastboot
and you'll be certain to avoid slow checks (or worse - a total failue if a check fails and the reboot halts)
I use the following perl script to check when the next fsck will occur:
I have it run in my ~/.bashrc so I always know when my filesystems will be checked, though I use ext4 now which doesn't suffer from extended fsck times, it's still nice to know.
Typical output is something like:
I regularly use tunefs to reset boot counts and time before doing a mid-day reboot, to prevent fsck. The difference in boot time is stunning. Afterwords I reset them to allow the next boot to fsck.
I thought about how to get a list of filesystems more comfortably:
I guess it could be done more elegantly but anyway here it is. If one pipes this into
xargs -r df -h
one could also quickly see how large the filesystems are.Note that in the code above the time of "Next check" is compared to (NOW + 120 seconds) assuming that it takes some time until your system gets up again.
HTH
Here is a script that checks your filesystems for fsck (source):