summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2001-08-07 07:04:12 +0000
committerBill Nottingham <notting@redhat.com>2001-08-07 07:04:12 +0000
commit9e0adb7706d937a19442f4d697f2204750330cff (patch)
tree47fbe31553101ee3ee129ca31688a7bf1e8df007
parent2daa66fee0b1471dbd2e9c8a97b2776fec892ad5 (diff)
downloadinitscripts-9e0adb7706d937a19442f4d697f2204750330cff.tar.gz
initscripts-9e0adb7706d937a19442f4d697f2204750330cff.tar.xz
initscripts-9e0adb7706d937a19442f4d697f2204750330cff.zip
detach loopback devices at shutdown (#43919, #45826)
-rwxr-xr-xrc.d/init.d/halt6
-rwxr-xr-xrc.d/init.d/netfs6
2 files changed, 10 insertions, 2 deletions
diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt
index 8328a473..28b62de7 100755
--- a/rc.d/init.d/halt
+++ b/rc.d/init.d/halt
@@ -127,7 +127,7 @@ SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
# Unmount file systems, killing processes if we have to.
# Unmount loopback stuff first
-remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts`
+remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts`
[ -n "$remaining" ] && {
sig=
retry=3
@@ -138,6 +138,10 @@ remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/moun
else
runcmd $"Unmounting loobpack filesystems: " umount $remaining
fi
+ for dev in $remaining ; do
+ losetup $dev > /dev/null 2>&1 && \
+ runcmd $"Detaching loopback device $dev: " losetup -d $device
+ done
remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts`
[ -z "$remaining" ] && break
/sbin/fuser -k -m $sig $remaining >/dev/null
diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs
index 4ffed775..4a6a215f 100755
--- a/rc.d/init.d/netfs
+++ b/rc.d/init.d/netfs
@@ -45,7 +45,7 @@ case "$1" in
;;
stop)
# Unmount loopback stuff first
- remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts`
+ remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts`
[ -n "$remaining" ] && {
sig=
retry=3
@@ -56,6 +56,10 @@ case "$1" in
else
action $"Unmounting loopback filesystems: " umount $remaining
fi
+ for dev in $remaining ; do
+ losetup $dev >/dev/null 2>&1 && \
+ action $"Detaching loopback device $dev: " losetup -d $dev
+ done
remaining=`awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts`
[ -z "$remaining" ] && break
/sbin/fuser -k -m $sig $remaining >/dev/null