diff options
Diffstat (limited to 'rc.d')
-rwxr-xr-x | rc.d/init.d/halt | 9 | ||||
-rwxr-xr-x | rc.d/init.d/network | 2 | ||||
-rwxr-xr-x | rc.d/rc.sysinit | 30 |
3 files changed, 25 insertions, 16 deletions
diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt index 2e5d8150..3242491a 100755 --- a/rc.d/init.d/halt +++ b/rc.d/init.d/halt @@ -11,6 +11,9 @@ NOLOCALE=1 . /etc/init.d/functions +UMOUNT="umount" +[ ! -w /etc ] && UMOUNT="umount -n" + action() { echo -n "$1 " shift @@ -131,7 +134,7 @@ esac # Try to unmount tmpfs filesystems to avoid swapping them in. Ignore failures. tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; } $3 == "tmpfs" { print $2; }' /proc/mounts | sort -r) -[ -n "$tmpfs" ] && fstab-decode umount $tmpfs 2>/dev/null +[ -n "$tmpfs" ] && fstab-decode $UMOUNT $tmpfs 2>/dev/null # Turn off swap, then unmount file systems. [ -f /proc/swaps ] && SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps` @@ -170,7 +173,7 @@ LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next} $"Unmounting file systems (retry): " \ -f -[ -f /proc/bus/usb/devices ] && umount /proc/bus/usb +[ -f /proc/bus/usb/devices ] && $UMOUNT /proc/bus/usb [ -f /etc/crypttab ] && \ LANG=C action $"Stopping disk encryption: " halt_crypto @@ -183,7 +186,7 @@ rm -f /.autofsck awk '$2 !~ /\/(|dev|proc|selinux)$/ && $1 !~ /^\/dev\/ram/ { print $2 }' \ /proc/mounts | sort -r | \ while read line; do - fstab-decode umount -f $line + fstab-decode $UMOUNT -f $line done if [ -x /sbin/halt.local ]; then diff --git a/rc.d/init.d/network b/rc.d/init.d/network index 9efb67bc..e209b3a8 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -171,7 +171,7 @@ case "$1" in stop) # Don't shut the network down if root is on NFS or a network # block device. - rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab) + rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/" && $3 != "rootfs") { print $3; }}' /proc/mounts) rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) if [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev|_rnetdev" ]] ; then diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit index ea9c6884..7f28783b 100755 --- a/rc.d/rc.sysinit +++ b/rc.d/rc.sysinit @@ -595,7 +595,7 @@ if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then /bin/true elif [ x$state_mount_dev != x ] && mount $state_mount_dev $mountopts "$STATE_MOUNT" > /dev/null 2>&1; then /bin/true - elif [ -n "$CLIENTSTATE" ]; then + elif [ ! -z "$CLIENTSTATE" ]; then # No local storage was found. Make a final attempt to find # state on an NFS server. @@ -730,23 +730,29 @@ if [ -n "$SELINUX_STATE" ]; then restorecon /etc/mtab /etc/ld.so.cache /etc/blkid/blkid.tab /etc/resolv.conf >/dev/null 2>&1 fi -# Clear mtab -(> /etc/mtab) &> /dev/null +if [ "$READONLY" != "yes" ] ; then + # Clear mtab + (> /etc/mtab) &> /dev/null -# Remove stale backups -rm -f /etc/mtab~ /etc/mtab~~ + # Remove stale backups + rm -f /etc/mtab~ /etc/mtab~~ -# Enter mounted filesystems into /etc/mtab -mount -f / -mount -f /proc >/dev/null 2>&1 -mount -f /sys >/dev/null 2>&1 -mount -f /dev/pts >/dev/null 2>&1 -mount -f /proc/bus/usb >/dev/null 2>&1 + # Enter mounted filesystems into /etc/mtab + mount -f / + mount -f /proc >/dev/null 2>&1 + mount -f /sys >/dev/null 2>&1 + mount -f /dev/pts >/dev/null 2>&1 + mount -f /proc/bus/usb >/dev/null 2>&1 +fi # Mount all other filesystems (except for NFS and /proc, which is already # mounted). Contrary to standard usage, # filesystems are NOT unmounted in single user mode. -action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs -O no_netdev +if [ "$READONLY" != "yes" ] ; then + action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs -O no_netdev +else + action $"Mounting local filesystems: " mount -a -n -t nfs4,smbfs,ncpfs,cifs,gfs -O no_netdev +fi if [ -x /sbin/quotaon ]; then action $"Enabling local filesystem quotas: " /sbin/quotaon -aug |