Index: init.d/halt.sh =================================================================== --- init.d/halt.sh (revision 1362) +++ init.d/halt.sh (working copy) @@ -7,6 +7,13 @@ source /sbin/livecd-functions.sh && \ livecd_read_commandline +# livecd-functions.sh should _ONLY_ set this differently if CDBOOT is +# set, else the default one should be used for normal boots. +# say: RC_NO_UMOUNTS="/newroot|/memory|/mnt/cdrom|/mnt/livecd" +RC_NO_UMOUNTS=${RC_NO_UMOUNTS:-/newroot|/memory} + +RC_NO_UMOUNT_FS="^(proc|devpts|sysfs|devfs|tmpfs|usb(dev)?fs|unionfs)$" + # Reset pam_console permissions if we are actually using it if [[ -x /sbin/pam_console_apply && ! -c /dev/.devfsd && \ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ]]; then @@ -101,7 +108,7 @@ # Remove loopback devices started by dm-crypt remaining=$(awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts | \ - sort -r | grep -v '/newroot' | grep -v '/mnt/livecd') + sort -r | egrep -v "^(${RC_NO_UMOUNTS})$") [[ -n ${remaining} ]] && { sig= retry=3 @@ -118,7 +125,7 @@ fi remaining=$(awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts | \ - sort -r | grep -v '/newroot' | grep -v '/mnt/livecd') + sort -r | egrep -v "^(${RC_NO_UMOUNTS})$") [[ -z ${remaining} ]] && break /bin/fuser -k -m ${sig} ${remaining} &>/dev/null @@ -132,17 +139,17 @@ # This is needed to make sure we dont have a mounted filesystem # on a LVM volume when shutting LVM down ... ebegin "Unmounting filesystems" -unmounts=$( \ - awk '{ \ - if (($3 !~ /^(proc|devpts|sysfs|devfs|tmpfs|usb(dev)?fs)$/) && \ +unmounts=$(awk -v NO_UMOUNT_FS="${RC_NO_UMOUNT_FS}" \ + '{ \ + if (($3 !~ NO_UMOUNT_FS) && \ ($1 != "none") && \ ($1 !~ /^(rootfs|\/dev\/root)$/) && \ ($2 != "/")) \ - print $2 }' /proc/mounts | sort -ur) + print $2 \ + }' /proc/mounts | sort -ur) for x in ${unmounts}; do - # Do not umount these if we are booting off a livecd - if [[ -n ${CDBOOT} ]] && \ - [[ ${x} == "/mnt/cdrom" || ${x} == "/mnt/livecd" ]] ; then + # Do not umount these ... will be different depending on value of CDBOOT + if [[ -n $(echo "${x}" | egrep "^(${RC_NO_UMOUNTS})$") ]] ; then continue fi @@ -193,8 +200,15 @@ sync; sync sleep 1 - for x in $(awk '$1 != "none" { print $2 }' /proc/mounts | sort -ur) ; do + for x in $(awk -v NO_UMOUNT_FS="${RC_NO_UMOUNT_FS}" \ + '{ \ + if (($1 != "none") && ($3 !~ NO_UMOUNT_FS)) \ + print $2 \ + }' /proc/mounts | sort -ur) ; do x=${x//\\040/ } + if [[ -n $(echo "${x}" | egrep "^(${RC_NO_UMOUNTS})$") ]] ; then + continue + fi if [[ ${cmd} == "u" ]]; then umount -n -r "${x}" else