From 57592e6dc1ee59c1e98ac8ced0263ba3252c6972 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 25 Jan 2024 07:46:51 +1300 Subject: [PATCH] live-build/functions: avoid losetup -P as it appears to race with udev and do it a bit more by-hand instead. (LP: #2045586) --- debian/changelog | 7 +++++++ live-build/functions | 15 ++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 15eb1e35..d4aa3b35 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (24.04.21) UNRELEASED; urgency=medium + + * live-build/functions: avoid losetup -P as it appears to race with udev and + do it a bit more by-hand instead. (LP: #2045586) + + -- Michael Hudson-Doyle Thu, 25 Jan 2024 07:45:58 +1300 + livecd-rootfs (24.04.20) noble; urgency=medium * fix: Fix for calling unminimize if lxd-installer package diff --git a/live-build/functions b/live-build/functions index fe93c71f..bdd24b77 100644 --- a/live-build/functions +++ b/live-build/functions @@ -62,13 +62,26 @@ mount_image() { trap clean_loops EXIT backing_img="$1" local rootpart="$2" - loop_device=$(losetup --show -f -P -v ${backing_img}) + + # As explained in excruciating detail in LP: #2045586, "losetup + # -P" (a.k.a. --partscan) appears to race with udev in a way that + # prevents the device nodes for the partitions from being + # created. So instead we run losetup without -P, wait for udev to + # settle, then run partprobe and then settle udev again (which is + # probably unnecessary but at this point a bit more superstition + # can't hurt) + + loop_device=$(losetup --show -f -v ${backing_img}) if [ ! -b ${loop_device} ]; then echo "unable to find loop device for ${backing_img}" exit 1 fi + udevadm settle + partprobe ${loop_device} + udevadm settle + # Find the rootfs location rootfs_dev_mapper="${loop_device}p${rootpart}" if [ ! -b "${rootfs_dev_mapper}" ]; then