for s in /sys/block/${dev}/holders/dm-* ; do
# multipath devices might have MD devices on top,
# which are removed after this script. So do not
# remove those to avoid spurious errors
case $(cat /sys/block/${dev}/dm/uuid) in
devname=$(cat /sys/block/${dev}/dm/name)
dmsetup -v --noudevsync remove "$devname" || return $?
info "Disassembling device-mapper devices"
for dev in /sys/block/dm-* ; do
[ -e ${dev} ] || continue
if [ "x$final" != "x" ]; then
_remove_dm ${dev##*/} || ret=$?
_remove_dm ${dev##*/} >/dev/null 2>&1 || ret=$?
if [ "x$final" != "x" ]; then
dmsetup ls --tree 2>&1 | vinfo
if command -v dmsetup >/dev/null &&
[ "x$(dmsetup status)" != "xNo devices found" ]; then