home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
tusportal.tus.k12.pa.us
/
tusportal.tus.k12.pa.us.tar
/
tusportal.tus.k12.pa.us
/
Wyse
/
latest-image.raw
/
0.img
/
etc
/
init.d
/
boot.rootfsck
< prev
next >
Wrap
Text File
|
2010-05-05
|
6KB
|
202 lines
#! /bin/sh
#
# Copyright (c) 2001-2002 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# /etc/init.d/boot.rootfsck
#
### BEGIN INIT INFO
# Provides: boot.rootfsck
# Required-Start: boot.udev
# Required-Stop: $null
# Default-Start: B
# Default-Stop:
# Short-Description: check and mount root filesystem
# Description: check and mount root filesystem
### END INIT INFO
. /etc/rc.status
# to get max number of parallel fsck processes
. /etc/sysconfig/boot
export FSCK_MAX_INST
rc_reset
case "$1" in
start)
#
# fsck may need a huge amount of memory, so make sure, it is there.
#
echo "Activating swap-devices in /etc/fstab..."
swapon -ae &> /dev/null
rc_status -v1 -r
if rc_readonlyroot && test -z "$ROOTFS_FSCK" ; then
echo "Skipping fsck of read-only root filesystem."
# Pretend that the initrd already did a root filesystem check to skip the
# filesystem check we would do below.
ROOTFS_FSCK=0
fi
#
# do fsck and start sulogin, if it fails.
#
FSCK_RETURN=0
MAY_FSCK=1
# we may get ROOTFS_BLKDEV passed from initrd, skip extra actions
if [ -n "$ROOTFS_BLKDEV" ] ; then
if [ -n "$ROOTFS_REALDEV" ] ; then
ROOTFS_BLKDEV=$ROOTFS_REALDEV
fi
else
# if not booted via initrd, /dev is empty.
# use private devnode with proper permissions
ROOTFS_BLKDEV="/dev/shm/root"
rootcpio=`echo / | /bin/cpio --quiet -o -H newc`
rootmajor=0x${rootcpio:62:8}
rootminor=0x${rootcpio:70:8}
if [ $((rootmajor)) -ne 0 ] ; then
echo /bin/mknod -m600 $ROOTFS_BLKDEV b $((rootmajor)) $((rootminor))
/bin/mknod -m600 $ROOTFS_BLKDEV b $((rootmajor)) $((rootminor))
fi
fi
# common options for file system check
FSCK_OPTS="-a"
if test -f /forcefsck -o "$DO_FORCEFSCK" = "yes" ; then
# force file system check if forced is specified
FSCK_OPTS="$FSCK_OPTS -f"
ROOTFS_FSCK=""
fi
if test "$ROOTFS_FSCK" = "0" ; then
# already checked and ok, skip the rest
MAY_FSCK=0
else
ROOTFS_TYPE=`stat -f -c "%T" /`
case $ROOTFS_TYPE in
aufs|tmpfs|afs|cifs|nfs|novell|smb|UNKNOWN*) MAY_FSCK=0 ;;
*)
if test -x /usr/bin/on_ac_power ; then
# skip fsck if running on battery
/usr/bin/on_ac_power -q || MAY_FSCK=0
fi
;;
esac
fi
if test ! -f /fastboot -a "$DO_FASTBOOT" != "yes" -a $MAY_FSCK -eq 1 ; then
# If we use a serial console, don't use the fsck progress bar
if test "${REDIRECT##*/}" = "tty1" ; then
FSCK_OPTS="$FSCK_OPTS -C"
else
FSCK_OPTS="$FSCK_OPTS -V"
fi
# on an umsdos root fs this mount will fail,
# so direct error messages to /dev/null.
# this seems to be ugly, but should not really be a problem.
mount -n -o remount,ro / 2> /dev/null
if test $? = 0; then
if test -n "$ROOTFS_FSCK" ; then
# When the initrd checks the root filesystem, it stores the
# fsck exit status in ROOTFS_FSCK.
FSCK_RETURN=$ROOTFS_FSCK
else
echo "Checking root file system..."
fsck $FSCK_OPTS $ROOTFS_BLKDEV
# A return code of 1 indicates that file system errors
# were corrected, but that the boot may proceed.
# A return code of 2 or larger indicates failure.
FSCK_RETURN=$?
fi
test $FSCK_RETURN -lt 4
rc_status -v1 -r
if test $FSCK_RETURN -gt 1 -a $FSCK_RETURN -lt 4 ; then
# if appropriate, switch bootsplash to verbose
# mode to make text messages visible.
test -f /proc/splash && echo "verbose" > /proc/splash
echo
echo "fsck succeed, but reboot is required."
echo
sleep 1
sync
reboot -f
elif test $FSCK_RETURN -gt 3; then
# if appropriate, switch bootsplash to verbose
# mode to make text messages visible.
test -f /proc/splash && echo "verbose" > /proc/splash
# Stop blogd since we reboot after sulogin
test -x /sbin/blogd && killproc -QUIT /sbin/blogd
if test -x /etc/init.d/kbd ; then
/etc/init.d/kbd start
fi
echo
echo "fsck failed. Please repair manually and reboot. The root"
echo "file system is currently mounted read-only. To remount it"
echo "read-write do:"
echo
echo " bash# mount -n -o remount,rw /"
echo
echo "Attention: Only CONTROL-D will reboot the system in this"
echo "maintanance mode. shutdown or reboot will not work."
echo
PS1="(repair filesystem) # "
export PS1
/sbin/sulogin /dev/console
# if the user has mounted something rw, this should be umounted
echo "Unmounting file systems (ignore error messages)"
umount -avn
# on umsdos fs this would lead to an error message.
# so direct errors to /dev/null
mount -no remount,ro / 2> /dev/null
sync
reboot -f
fi
sync
mount -n -o remount,rw /
test $FSCK_RETURN -gt 0 && > /fsck_corrected_errors
else
echo
echo '*** ERROR! Cannot fsck because root is not read-only!'
echo
fi
else
if test "$ROOTFS_FSCK" != "0" ; then
echo "root file system (/) is NOT being checked."
fi
fi
# If /etc is not writable, mount currently requires that /etc/mtab is a
# symlink. (Else, it will try to create /etc/mtab.$PID and /etc/mtab~.)
if test ! -L /etc/mtab ; then
# start with a clean mtab and enter root fs entry
rm -f /etc/mtab*
> /etc/mtab
mount -f /
fi
;;
stop)
;;
restart)
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking if boot.rootfsck has run"
rc_reset
grep -q " / " /etc/mtab || rc_failed 3
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
rc_exit