I'm just curious - why do all linux distros (all I've seen) run their periodic disk checks during boot? I mean, I understand that a disk should be checked now and then, but why does the system do it during boot, when I'm waiting for it to load, instead of checking them during shutdown, when (most probably) user doesn't need the computer anymore.

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
If this question can be reworded to fit the rules in the help center, please edit the question.

Running disk check on system shutdown is a bad idea because the filesystem or the system itself might be in a corrupt state. During boot everything is "reset" and in a well defined state so it is less likely that you encounter problems caused by programming errors that might compromise your filessystem(s).
–
WaxheadDec 11 '11 at 23:00

5 Answers
5

I agree with your opinion. This is a dubious design and even worse, by murphy law, the fsck will usually happen the day when you are most in a hurry. However, nothing prevents you to add a rc task that will check your file systems at shutdown time if their counters is close to the limit. An even better solution would be to use a file system (possibly on another OS) that doesn't need fsck at all, like ZFS.

so, you would rather work on a faulty system and possibly lose the work of a day than getting informed BEFORE you start to work?

for most users it is better to get informed about potentiall problems BEFORE they write stuff to their disk and thus this is the default behavior. nevertheless, you can run the filesystem checks on your system whenever you want.

As the disk is extremely unlikely to have its content modified when powered off, I don't think your "BEFORE" point is that much valid. Whether the check is done just before the computer is turned off or just before the file system is mounted at boot time is mostly equivalent.
–
jlliagreDec 3 '10 at 11:38

@jiliagre: the content is not modified at shutdown because it was modified BEFORE :) and it is not equivalent because you shut down a system, take the disk somewhere, wait a month, put it into another computer. you do not check an airplane when you leave the cockpit but when you enter it and are ready to lift off.
–
akiraDec 3 '10 at 13:46

Before each workphase comes: 1 Shutdown, 1 Off, 1 Boot. We can't check during the Off-phase, but we can check during either Shutdown or Boot, and I agree that unless the PC got moved much it should make no difference which you choose but Shutdown is more comfortable for the user. In an ideal world it would check again on boot if the an always-on movement sensor recorded cases of drastic movement and/or the PC was off for a long time.
–
Carighan MaconarDec 3 '10 at 14:30

Dust and other contamination can cause havoc to a harddrive after having it stored. For instance if you forget to close a window and leave your house for a week or simply turn off the heat condensation and/or other contamination might cause your disk not be in the same state as it was when turned off. There are probably a gazillion other things as well that might happen to your harddrive when turned of for a longer period like oil from the bearings leaking out on the platter, dust particles etc etc...
–
WaxheadDec 11 '11 at 23:06

If I were a programmer I'd submit a patch for shutdown that displays a dialog: "The filesystem on /dev/sdd4 will need to be checked after 2 more reboots. Would you like to check it now, or wait until later?" (Same for halt and the other shutdown-like commands.)

Of course, this being Linux I shut down my desktop box only for kernel installs, so it's not a huge issue.

I like your idea.. You should request that as a feature on something like http://brainstorm.ubuntu.com/. Let others vote it up, and see if it can get implemented.. (or if there are technical reasons why not).. I love the 12 second boot on my SSD, I hate it when it becomes a 2 min boot because of fsck.. I like CarlF's idea about a dialog warning you, so you can run it early.