From 8054e5692b9dfbc76382b474c1f747adeb01f1d5 Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Thu, 17 Jan 2008 11:19:09 +0000 Subject: [PATCH] Stefan Fiedler: sysfiles: in the localfs init script, fsck the root fs only if it can be mounted read-only; also only reboot if the fsck return code suggests to do so [2007112718564298570] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@8932 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/base/sysfiles/localfs.init | 33 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/package/base/sysfiles/localfs.init b/package/base/sysfiles/localfs.init index ba7923c35..4692aa0a8 100644 --- a/package/base/sysfiles/localfs.init +++ b/package/base/sysfiles/localfs.init @@ -28,16 +28,31 @@ main_begin block_begin(start, `Checking file systems.') - fsck -A -C -a ; fsckrc=$? - if [ $(( $fsckrc & ~3 )) != 0 ] ; then - echo " **" - echo " ** Filesystem check failed (returncode=$fsckrc)." - echo " ** Please repair the broken disk(s) manually." - echo " **" + if ! mount / -o remount,ro ; then + fsck_root=-R + fi + fsck -A -C -a $fsck_root ; fsckrc=$? + if [ "$fsckrc" != 0 ] ; then + echo "'fsck -A -C -a $fsck_root' returned the following:" + [ $(( $fsckrc & 1 )) != 0 ] && echo "file system errors corrected" + [ $(( $fsckrc & 2 )) != 0 ] && echo "system should be rebooted" + [ $(( $fsckrc & 4 )) != 0 ] && echo "file system errors left uncorrected" + [ $(( $fsckrc & 8 )) != 0 ] && echo "operational error" + [ $(( $fsckrc & 16 )) != 0 ] && echo "usage or syntax error" + [ $(( $fsckrc & 32 )) != 0 ] && echo "fsck canceled by user request" + [ $(( $fsckrc & 128 )) != 0 ] && echo "shared library error" + fi + echo + if [ $(( $fsckrc & 4 )) != 0 ] ; then + echo " Please repair the broken disk(s) manually." + if [ $(( $fsckrc & 2 )) != 0 ] ; then + echo "When you exit the shell, the system will reboot as recommended by fsck." + else + echo "Afterwards, exit the shell to continue booting or reboot the system if needed." + fi sulogin -t 600 /dev/console - umount -adrv ; /sbin/reboot -d -f - while true ; do sleep 1 ; done - elif [ $(( $fsckrc & 2 )) != 0 ] ; then + fi + if [ $(( $fsckrc & 2 )) != 0 ] ; then for x in 10 9 8 7 6 5 4 3 2 ; do echo -en "\rSystem reboot in $x seconds ... " sleep 1