Package: live-build Version: 1:20170807 Followup-For: Bug #865586 Hi,
I also ran into this same error a while ago. It is caused by partition devices being created when parted creates partitions, which are not cleaned up when the loop devices are cleaned up. I'm attaching a patch that fixes this, by passing --partscan to losetup to clear out any lingering partition devices when the partition itself is mounted. It would be more correct to clean up the partition devices when the loop device is removed, but I'm not quite sure whose responsibility that would be. Gr. Matthijs
>From 05e0703d82e0189e40d88f5070b1c2f955a0ad9e Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman <matth...@stdin.nl> Date: Tue, 29 Aug 2017 15:04:31 +0200 Subject: [PATCH 3/4] Pass --partscan to losetup Recent versions of Linux, parted or some other bit of software cause partition devices, like /dev/loop0p1 to be created when running parted mkpart. However, these devices are not cleaned up when running losetup -d to remove /dev/loop0 later, so they linger around and confuse mkfs (which refuses to make a filesystem, thinking there are partitions): mkfs.fat 4.1 (2017-01-24) mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making filesystem (use -I to override) To prevent this behaviour, pass --partscan to losetup when adding a new partition, to clean up any lingering partitions. It seems losetup does not accept --partscan when deleting a loop device, to clean up at that point, but since binary_hdd mounts the partition last, there should not be any lingering partition devices after live-build is done. The --partscan option is available since util-linux 2.21 (released in 2012), so it should be fairly safe to pass it unconditionally. --- functions/losetup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/losetup.sh b/functions/losetup.sh index 0346ff677..9d9b46e5d 100755 --- a/functions/losetup.sh +++ b/functions/losetup.sh @@ -40,7 +40,7 @@ Losetup () FILE="${2}" PARTITION="${3:-1}" - ${LB_LOSETUP} --read-only "${DEVICE}" "${FILE}" + ${LB_LOSETUP} --read-only --partscan "${DEVICE}" "${FILE}" FDISK_OUT="$(${LB_FDISK} -l -u ${DEVICE} 2>&1)" Lodetach "${DEVICE}" @@ -50,14 +50,14 @@ Losetup () then Echo_message "Mounting %s with offset 0" "${DEVICE}" - ${LB_LOSETUP} "${DEVICE}" "${FILE}" + ${LB_LOSETUP} --partscan "${DEVICE}" "${FILE}" else SECTORS="$(echo "$FDISK_OUT" | sed -ne "s|^$LOOPDEVICE[ *]*\([0-9]*\).*|\1|p")" OFFSET="$(expr ${SECTORS} '*' 512)" Echo_message "Mounting %s with offset %s" "${DEVICE}" "${OFFSET}" - ${LB_LOSETUP} -o "${OFFSET}" "${DEVICE}" "${FILE}" + ${LB_LOSETUP} --partscan -o "${OFFSET}" "${DEVICE}" "${FILE}" fi } -- 2.11.0