Stop fsck running every 27 boots on Ubuntu

Q I tried to boot into my Ubuntu Gutsy and it wouldn't go. I got Grub just fine, selected the OS, and it went to the boot splash screen and the loading bar. It got only a short way up this bar before the screen went black with a cursor in the top-left of the screen. There it stayed and wouldn't go anywhere else. I suspect that it's something to do with the regular fsck checks that it was perhaps trying to perform, but could not. If this is the case, what can I do? It seems that Ubuntu performs an fsck check every 27 times on booting. I fixed it by booting into recovery mode and letting fsck run, but it's going to happen again isn't it? How can I stop it happening every 27 boots?

A Boot splash screens are very pretty, but they also hide any error messages that the system wants to show you. Some distros let you remove the splash screen mid-boot by pressing a key, usually Esc or F2, but Ubuntu no longer does this. You can stop the splash screen in the first place by editing the boot options. When the "Press Esc to enter the menu" text appears, do so. Then press E, for edit, highlight the kernel line and press E again. Remove "quiet splash" from the end of the kernel line and press Enter followed by B to boot with the changed setting. You should now see all the boot text and be able to see exactly what is stopping the boot process. The change you made is temporary, but you can edit /boot/grub/menu.lst to make it permanent, or copy the current boot stanza and edit that, to give you options to boot with or without a splash screen.

If a regular call to fsck is stopping the boot, it means that there's either a fault on the filesystem that fsck needs your input on before proceeding, or that fsck is taking a while and you haven't waited long enough. Booting without the splash screen will tell you which. Once fsck has completed successfully, you should not have this problem again, unless there is something wrong with your system that is causing filesystem corruption. One way to avoid the automated fsck is to regularly run it manually, so you should never go 27 mounts without a check. You can also use tune2fs to set the intervals between checks.

tune2fs -c 0 /dev/whatever
tune2fs -i 2w /dev/whatever

will tell it to ignore the mount count with the first command and to check every two weeks with the second. It is very unwise to disable both of these, otherwise filesystem corruption could build without you knowing until a serious failure occurs. If you want to get really clever, you could add something like this to a daily Cron script:

MOUNTS="$(tune2fs -l /dev/whatever | awk
'/^Mount count/ {print $3}')
if [[ $MOUNTS > 20 ]]
echo "dev/whatever has been mounted
$MOUNTS times since the last check, run fsck
on it now."

This will email you when the mount count exceeds 20, giving you the chance to run it manually. The second line looks complicated, but it just runs tune2fs to list the filesystem information and extracts the mount count with awk.

Follow us on or Twitter

Username:   Password:
Create Account | About TuxRadar