# Write to wtmp file before unmounting /var
halt -w
-if ! is_yes "$VSERVER"; then
- # Turn off swap, then unmount file systems.
- run_cmd "Turning off swap" swapoff -a
+# Turn off swap, then unmount file systems.
+run_cmd "Turning off swap" swapoff -a
- [ -x /etc/rc.d/rc.acct ] && /etc/rc.d/rc.acct stop
+[ -x /etc/rc.d/rc.acct ] && /etc/rc.d/rc.acct stop
- if [ -x /sbin/quotaoff ]; then
- run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a
- fi
+if [ -x /sbin/quotaoff ]; then
+ run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a
+fi
- # grab kexec_loaded state before we umount /sys
- kexec_loaded=`cat /sys/kernel/kexec_loaded 2>/dev/null`
+# grab kexec_loaded state before we umount /sys
+kexec_loaded=`cat /sys/kernel/kexec_loaded 2>/dev/null`
- # Unmount file systems, killing processes if we have to.
- sig=-15
- retry=3
- force=
- if [ -z "$UMOUNT_IGNORE" ]; then
- UMOUNT_IGNORE="/"
- else
- UMOUNT_IGNORE="/ $UMOUNT_IGNORE"
- fi
- remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
- $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \
- && $1 !~ /^(none|\/dev\/root)$/ \
- && $2 !~ ig {print $2}' /proc/mounts)
- while [ -n "$remaining" -a "$retry" -gt 0 ]; do
- show "Unmounting file systems"; busy
- ERRORS=$(umount -a $force -t noproc 2>&1); rc=$?
+# Unmount file systems, killing processes if we have to.
+sig=-15
+retry=3
+force=
+if [ -z "$UMOUNT_IGNORE" ]; then
+ UMOUNT_IGNORE="/"
+else
+ UMOUNT_IGNORE="/ $UMOUNT_IGNORE"
+fi
+remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
+ $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|cgroup|cgroup2|sysfs|securityfs|efivarfs|squashfs)$/ \
+ && $1 !~ /^(none|\/dev\/root)$/ \
+ && $2 !~ ig {print $2}' /proc/mounts)
+while [ -n "$remaining" -a "$retry" -gt 0 ]; do
+ for mnt in $remaining; do
+ run_cmd "$(nls 'Umounting file system: %s' $mnt)" umount $force -R $mnt
# we might had unmounted /usr, recheck $TPUT availability
# but well. we need tput only for show() and busy() (ok() and fail() messages are already cached)
# TODO: look ahead the messages?
if is_yes "$TPUT"; then
- TPUT=
- rc_gettext_init
- fi
-
- if [ $rc = 0 ]; then
- ok
- else
- fail
- [ -n "$ERRORS" ] && echo "$ERRORS"
+ TPUT=
+ rc_gettext_init
fi
-
- sleep 2
- remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
- $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|sysfs|securityfs|squashfs)$/ \
- && $1 !~ /^(none|\/dev\/root)$/ \
- && $2 !~ ig {print $2}' /proc/mounts)
- [ -z "$remaining" ] && break
- fuser -k -m $sig $remaining > /dev/null
- sleep 5
- retry=$(($retry-1))
- sig=-9
- force="-f"
done
- run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
+ show "Unmounting remainging file systems"; busy
+ ERRORS=$(umount -a $force -t noproc,nosysfs,notmpfs,nodevpts,nodevtmpfs 2>&1); rc=$
- if [ -x /sbin/vgchange ]; then
- lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
- if [ "$lvmversion" = "2" ]; then
- lvmsysinit="--sysinit"
- else
- lvmsysinit=""
- fi
- /sbin/vgchange -a n $lvmsysinit > /dev/null 2>&1
+ # we might had unmounted /usr, recheck $TPUT availability
+ # but well. we need tput only for show() and busy() (ok() and fail() messages are already cached)
+ # TODO: look ahead the messages?
+ if is_yes "$TPUT"; then
+ TPUT=
+ rc_gettext_init
fi
- if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
- if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
- /sbin/mdadm --stop --scan > /dev/null 2>&1
- rc=$?
+ if [ $rc = 0 ]; then
+ ok
+ else
+ fail
+ if [ -n "$ERRORS" ]; then
+ nls "Umount errors:"
+ echo "$ERRORS"
fi
fi
- show "Remounting remaining filesystems ro mode"; busy
- if mount | awk '/ext2|ext3|reiserfs|xfs|jfs/ { print $3 }' | while read line; do mount -n -o ro,remount $line; done; then
- ok
+ sleep 2
+ remaining=$(awk -v ig="^($UMOUNT_IGNORE)$" 'BEGIN { gsub(/[\t ]+/, "|", ig); } \
+ $3 !~ /^(proc|loopfs|devpts|devtmpfs|shm|iso9660|ramfs|tmpfs|cgroup|cgroup2|sysfs|securityfs|efivarfs|squashfs)$/ \
+ && $1 !~ /^(none|\/dev\/root)$/ \
+ && $2 !~ ig {print $2}' /proc/mounts)
+ [ -z "$remaining" ] && break
+ fuser -k -m $sig $remaining > /dev/null
+ sleep 5
+ retry=$(($retry-1))
+ sig=-9
+ force="-f"
+done
+
+run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
+
+if [ -x /sbin/vgchange ]; then
+ lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
+ if [ "$lvmversion" = "2" ]; then
+ lvmsysinit="--sysinit --noudevsync"
else
- fail
+ lvmsysinit=""
fi
- _rebootwhat="system"
+ /sbin/vgchange -a n $lvmsysinit > /dev/null 2>&1
+fi
+
+if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
+ if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
+ /sbin/mdadm --stop --scan > /dev/null 2>&1
+ rc=$?
+ fi
+fi
+
+show "Remounting remaining filesystems ro mode"; busy
+if mount | awk '/ext2|ext3|reiserfs|xfs|jfs/ { print $3 }' | while read line; do mount -n -o ro,remount $line; done; then
+ ok
else
- _rebootwhat="vserver"
+ fail
fi
+_rebootwhat="system"
if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
. /etc/rc.d/init.d/cryptsetup