Create a new file /etc/init.d/checkroot containing:
!/bin/sh
# Begin /etc/init.d/checkroot
echo "Activating swap..."
/sbin/swapon -av
if [ -f /fastboot ]
then
echo "Fast boot, no file system check"
else
/bin/mount -n -o remount,ro /
if [ $? = 0 ]
then
if [ -f /forcecheck ]
then
force="-f"
else
force=""
fi
echo "Checking root file system..."
/sbin/fsck $force -a /
if [ $? -gt 1 ]
then
echo
echo "fsck failed. Please repair your file system manually by"
echo "running fsck without the -a option"
echo
echo "Please note that the file system is currently mounted in"
echo "read-only mode."
echo
echo "I will start sulogin now. CTRL+D will reboot your system."
/sbin/sulogin
/reboot -f
fi
else
echo "Cannot check root file system because it is not mounted in"
echo "read-only mode."
fi
fi
# End /etc/init.d/checkroot