How to run fsck during a shutdown sequence, or how to run one-time init scripts?
I want to be able to run fsck at, or near, shutdown at the end of the day, and not have to wait for it when booting (important now that I have 1TB drives!). As far as I can tell, the only way to arrange to run fsck on the root partition is if it is unmounted and I believe that only occurs at reboot time.
So, I thought of using the /forcefsck file that, when exists, will force file system check upon the next boot. So I envision having a script that touches that file, or issues the right shutdown command, then lets the system reboot and thus forcing a fsck of the root partition. However, I then want the system to turn right around and then shutdown, so that when I cold boot the system in the morning, I won't see the fsck run at that time, ever. So I think this boils down to being able to run a one-time init script or something like that. Is there an established way or idiom for running an init script only one time? I know I can create a non-standard init-script that looks for a special file like is done for /forcefsck, and only shutdown if that file is seen, but surely someone else has already come up with a canned solution/init-script to what I want to do. ;) bg |
You could create an init script that moves itself then runs shutdown.
The question I suppose needs to be asked, though, is: why are you running fsck at all? Dave |
Quote:
I wonder if there is some more direct way to just fsck the root partition at shutdown, and then just directly shutdown, instead of the funky script approach above. Quote:
Are you implying that running fsck is wrong in this context? Note that my root partition and data drives are all either ext3 or ext4 partitions. bg |
ext4 fsck should be quicker by nature (after the first one). Very full big drives would still be an issue.
|
If I were you, I'd probably just switch it off (despite the dire warnings in the tune2fs man page).
Set the 6th (last) field in /etc/fstab to 0 and the problem goes away. Dave |
Quote:
bg |
All times are GMT -5. The time now is 03:54 PM. |