Work around kpartx's nonzero exit due to "Device or resource busy" errors

which still permit kpartx to finally remove loop device (LP: #1684090).
Also sync before calling kpartx to let writing to loop devices finish.
ubuntu/artful
Balint Reczey 8 years ago
parent e89c54b271
commit 21efeb6795

5
debian/changelog vendored

@ -5,6 +5,11 @@ livecd-rootfs (2.442) UNRELEASED; urgency=medium
comparison prior to aa-series (LP: #1681548) comparison prior to aa-series (LP: #1681548)
* live-build/ubuntu-cpc/hooks/999-extras.binary: Exit on first failure * live-build/ubuntu-cpc/hooks/999-extras.binary: Exit on first failure
[Balint Reczey]
* sync before calling kpartx to let writing to loop devices finish
* Work around kpartx's nonzero exit due to "Device or resource busy" errors
which still permit kpartx to finally remove loop device (LP: #1684090)
-- Steve Langasek <steve.langasek@ubuntu.com> Thu, 13 Apr 2017 10:38:04 -0700 -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 13 Apr 2017 10:38:04 -0700
livecd-rootfs (2.441) zesty; urgency=medium livecd-rootfs (2.441) zesty; urgency=medium

@ -11,9 +11,22 @@ backing_img=
apt-get -qqy install dosfstools gdisk apt-get -qqy install dosfstools gdisk
clean_loops() { clean_loops() {
local kpartx_ret
local kpartx_stdout
if [ -n "${backing_img}" ]; then if [ -n "${backing_img}" ]; then
kpartx -v -d "${backing_img}" # sync before removing loop to avoid "Device or resource busy" errors
sync
kpartx_ret=""
kpartx_stdout=$(kpartx -v -d "${backing_img}") || kpartx_ret=$?
echo "$kpartx_stdout"
if [ -n "$kpartx_ret" ]; then
if echo "$kpartx_stdout" | grep -q "loop deleted: "; then
echo "Suppressing kpartx returning error (#860894)"
else
exit $kpartx_ret
fi
fi
unset backing_img unset backing_img
fi fi

Loading…
Cancel
Save