From 641fb51a1aa490bc7b5fcaf5ed97bdde144bb38a Mon Sep 17 00:00:00 2001 From: Arseny Maslennikov Date: Fri, 6 Sep 2024 14:10:05 +0300 Subject: [PATCH startup.git v2] halt: treat /usr as / To: devel@lists.altlinux.org If /usr is its own mountpoint, we have to treat it as one of the last remaining filesystems before the system is halted, since it e. g. hosts /usr/sbin/reboot. Link: https://bugzilla.altlinux.org/51235 Link: https://altlinux.org/Usrmerge Suggested-by: Sergey Y. Afonin Signed-off-by: Arseny Maslennikov --- startup/rc.d/init.d/halt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/startup/rc.d/init.d/halt b/startup/rc.d/init.d/halt index 1464d08..8e0eacf 100755 --- a/startup/rc.d/init.d/halt +++ b/startup/rc.d/init.d/halt @@ -148,19 +148,19 @@ SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps` # Unmount supermount and autofs*. UnmountFilesystems 3 5 \ - '$2 != "/" && (($3 == "supermount") || ($3 == "autofs") || ($3 == "autofs4")) {print $2}' \ + '$2 != "/" && $2 != "/usr" && ($3 ~ "^(supermount|autofs[0-9]*)$") {print $2}' \ 'Unmounting automount filesystem' \ 'Unmounting automount filesystem (retry)' # Unmount loopback stuff first. UnmountFilesystems 3 5 \ - '$2 != "/" && $1 ~ /^\/dev\/loop/ {print $2}' \ + '$2 != "/" && $2 != "/usr" && $1 ~ /^\/dev\/loop/ {print $2}' \ 'Unmounting loopback filesystem' \ 'Unmounting loopback filesystem (retry)' # Unmount all the rest. UnmountFilesystems 3 5 \ - '$2 != "/" && $2 !~ /^\/(dev|proc|sys)(\/.*)?$/ && $1 !~ /^none$/ {print $2}' \ + '$2 != "/" && $2 != "/usr" && $2 !~ /^\/(dev|proc|sys)(\/.*)?$/ && $1 !~ /^none$/ {print $2}' \ 'Unmounting filesystem' \ 'Unmounting filesystem (retry)' @@ -188,6 +188,9 @@ fi # Unmount and remount read-only anything that's left mounted. action 'Remounting remaining filesystems (if any) read-only:' \ umount -afnr -t noproc,nosysfs,notmpfs,nodevfs,nodevtmpfs,nousbfs,norpc_pipefs,nonfsd +if mountpoint -q /usr; then + action 'Remounting usr filesystem read-only:' mount -n -o remount,ro /usr +fi action 'Remounting root filesystem read-only:' mount -n -o remount,ro / # See if this is a powerfail situation. -- 2.45.2