diff --git a/modules.d/90dm/dm-shutdown.sh b/modules.d/90dm/dm-shutdown.sh index 7e4f4a58..4e2e2602 100755 --- a/modules.d/90dm/dm-shutdown.sh +++ b/modules.d/90dm/dm-shutdown.sh @@ -1,11 +1,28 @@ #!/bin/sh +_remove_dm() { + local dev=$1 + local s + local devname + + for s in /sys/block/${dev}/holders/dm-* ; do + [ -e ${s} ] || continue + _remove_dm ${s##*/} + done + devname=$(cat /sys/block/${dev}/dm/name) + dmsetup -v --noudevsync remove "$devname" || return $? + return 0 +} + _do_dm_shutdown() { local ret=0 local final=$1 + local dev + info "Disassembling device-mapper devices" - for dev in $(dmsetup info -c --noheadings -o name) ; do - dmsetup -v --noudevsync remove "$dev" || ret=$? + for dev in /sys/block/dm-* ; do + [ -e ${dev} ] || continue + _remove_dm ${dev##*/} || ret=$? done if [ "x$final" != "x" ]; then info "dmsetup ls --tree"