Creating the checkroot script

Create a new file /etc/init.d/checkroot containing the following:



#!/bin/sh
# Begin /etc/init.d/checkroot

echo -n "Activating swap..."
/sbin/swapon -a

if [ -f /fastboot ]
then
  echo "Fast boot, no file system check"

  /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 /sbin/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."
      echo
              /sbin/sulogin
              /sbin/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