2 # checkroot.sh Check to root filesystem.
4 # Version: @(#)checkroot.sh 2.84 25-Jan-2002 miquels@cistron.nl
10 # Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to be spawned
11 # from this script *before anything else* with a timeout, like SCO does.
13 test "$SULOGIN" = yes && sulogin
-t 30 $CONSOLE
16 # Ensure that bdflush (update) is running before any major I/O is
17 # performed (the following fsck is a good example of such activity :).
19 test -x /sbin
/update
&& update
30 while read fs mnt
type opts dump pass junk
38 test "$type" = swap
&& swap_on_md
=yes
43 # Might be a swapfile.
44 test "$type" = swap
&& swap_on_md
=yes
47 test "$type" = devfs
&& devfs
="$fs"
48 test "$mnt" != / && continue
50 test "$pass" = 0 -o "$pass" = "" && rootcheck
=no
60 # Activate the swap device(s) in /etc/fstab. This needs to be done
61 # before fsck, since fsck can be quite memory-hungry.
64 test -d /proc
/1 || mount
-n /proc
67 if test $swap_on_md = yes && grep -qs resync
/proc
/mdstat
69 test "$VERBOSE" != no
&& echo "Not activating swap - RAID array resyncing"
80 test "$VERBOSE" != no
&& echo "Activating swap"
81 swapon
-a 2> /dev
/null
85 # Check the root filesystem.
87 if test -f /fastboot ||
test $rootcheck = no
89 test $rootcheck = yes && echo "Fast boot, no filesystem check"
92 # Ensure that root is quiescent and read-only before fsck'ing.
94 mount
-n -o remount
,ro
/
103 if test "$FSCKFIX" = yes
111 dumb|network|unknown|
"") spinner
="" ;;
113 test `uname -m` = s390
&& spinner
="" # This should go away
114 test "$VERBOSE" != no
&& echo "Checking root filesystem..."
115 fsck
$spinner $force $fix /
117 # If there was a failure, drop into single-user mode.
119 # NOTE: "failure" is defined as exiting with a return code of
120 # 2 or larger. A return code of 1 indicates that filesystem
121 # errors were corrected but that the boot may proceed.
125 # Surprise! Re-directing from a HERE document (as in
126 # "cat << EOF") won't work, because the root is read-only.
128 echo "fsck failed. Please repair manually and reboot. Please note"
129 echo "that the root filesystem is currently mounted read-only. To"
130 echo "remount it read-write:"
132 echo " # mount -n -o remount,rw /"
134 echo "CONTROL-D will exit from this shell and REBOOT the system."
136 # Start a single user shell on the console
137 /sbin
/sulogin
$CONSOLE
141 echo "*** ERROR! Cannot fsck root fs because it is not mounted read-only!"
147 # If the root filesystem was not marked as read-only in /etc/fstab,
148 # remount the rootfs rw but do not try to change mtab because it
149 # is on a ro fs until the remount succeeded. Then clean up old mtabs
150 # and finally write the new mtab.
151 # This part is only needed if the rootfs was mounted ro.
153 echo "Remounting root file system..."
154 mount
-n -o remount
,$rootmode /
155 if test "$rootmode" = rw
157 if test ! -L /etc
/mtab
159 rm -f /etc
/mtab~
/etc
/nologin
162 mount
-f -o remount
/
164 test "$devfs" && grep -q '^devfs /dev' /proc
/mounts
&& mount
-f "$devfs"