92 lines
2.6 KiB
Bash
Executable File
92 lines
2.6 KiB
Bash
Executable File
#!/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
|
|
# Modified and maintained for openmamba by Silvan Calarco <silvan.calarco@mambasoft.it>
|
|
|
|
. /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..."
|
|
|
|
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
|
|
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 & 2)) -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 stop
|
|
elif [ $(($retval & 4)) -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 & 1)) -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
|
|
else
|
|
$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!"" (retval=$retval)"
|
|
echo_warning
|
|
echo
|
|
fi
|