initscripts/etc/rc.d/init.d/checkfs

91 lines
2.5 KiB
Plaintext
Raw Normal View History

2011-04-26 12:26:24 +02:00
#!/bin/sh
# checkfs - File System Check
# Based on checkfs script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
# Patch to handle all fsck variants by A. Luebke - luebke@users.sourceforge.net
. /etc/sysconfig/rc
. $rc_functions
if [ -f /fastboot ]; then
echo "Fast boot requested, will not perform file system checks"
exit 0
fi
echo -n "Checking file systems: "
$PLYMOUTH message --text=$"Checking file systems..."
2011-04-26 12:26:24 +02:00
if [ ! -e /run/initramfs/root-fsck ]; then
echo -n "Mounting root file system in read-only mode: "
mount -n -o remount,ro /
retval=$?
if [ $retval != 0 ]; then
$FAILURE
echo "Cannot check root file system because it could not"
echo "be mounted in read-only mode."
echo
$NORMAL
$PLYMOUTH message --text=$"Checking file systems...operational error!"
echo_warning
echo
else
echo_success
echo
fi
2011-04-26 12:26:24 +02:00
fi
if [ -f /forcefsck ]; then
echo "/forcefsck exists, forcing file system check"
options="-f"
else
options=""
fi
# note: -a option used to be -p; but this fails e.g. on fsck.minix
fsck $options -a -A -C -T
retval=$?
if [ $retval -eq 0 ]; then
$PLYMOUTH message --text=$"Checking file systems...done"
echo_success
echo
elif [ $retval -eq 1 ]; then
$WARNING
echo "File system errors were found and have been corrected."
echo "You may want to double-check that everything was fixed"
echo -n "properly"
$NORMAL
$PLYMOUTH message --text=$"Checking file systems...fixed"
echo_warning
echo
elif [ $retval -eq 2 ]; then
$WARNING
echo "File system errors were found and have been corrected, but"
echo "the nature of the errors require this system to be rebooted."
$NORMAL
$PLYMOUTH message --text=$"Checking file systems...rebooting"
echo_warning
echo
$rc_base/init.d/reboot
elif [ $retval -eq 4 ]; then
$WARNING
echo "File system errors were encountered that couldn't be"
echo "fixed automatically. The system will continue to boot but"
echo "errors need to be fixed manually by a system administrator."
$NORMAL
$PLYMOUTH message --text=$"Checking file systems...unfixable errors"
echo_warning
echo
elif [ "$retval" -gt 4 ]; then
$FAILURE
echo "An internal error was encountered while checking file systems."
echo "This system will continue to boot but errors need to be fixed"
echo "by a system administrator."
$NORMAL
$PLYMOUTH message --text=$"Checking file systems...operational error!"
echo_warning
echo
fi