Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion grml-debootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,13 @@ cleanup() {

if [ -n "${ORIG_TARGET}" ] ; then
einfo "Removing loopback mount of file ${ORIG_TARGET}."
kpartx -d "${ORIG_TARGET}" ; eend $?
kpartx -d "${ORIG_TARGET}"
# Workaround for a bug in kpartx which doesn't clean up properly,
# see Debian Bug #891077 and Github-PR grml/grml-debootstrap#112
if dmsetup ls | grep -q "^${LOOP_PART} "; then
kpartx -d "/dev/${LOOP_DISK}" >/dev/null
fi
eend $?
fi
}

Expand Down Expand Up @@ -1432,6 +1438,7 @@ prepare_vm() {
# hopefully this always works as expected
LOOP_PART="${DEVINFO##add map }" # 'loop0p1 (254:5): 0 20477 linear 7:0 3'
LOOP_PART="${LOOP_PART// */}" # 'loop0p1'
LOOP_DISK="${LOOP_PART%p*}" # 'loop0'
export TARGET="/dev/mapper/$LOOP_PART" # '/dev/mapper/loop1p1'

if [ -z "$TARGET" ] ; then
Expand Down Expand Up @@ -1516,6 +1523,11 @@ fi
try_umount 3 "${MNTPOINT}"/dev
umount "${MNTPOINT}"
kpartx -d "${ORIG_TARGET}" >/dev/null
# Workaround for a bug in kpartx which doesn't clean up properly,
# see Debian Bug #891077 and Github-PR grml/grml-debootstrap#112
if dmsetup ls | grep -q "^${LOOP_PART} "; then
kpartx -d "/dev/${LOOP_DISK}" >/dev/null
fi
}
# }}}

Expand Down