Check existing issues
Bug description
Discovered and researched by @smethnani.
When we create loop devices, there's a race condition we sometimes hit when trying to mount them before they fully exist.
The upstream version of this bug is in https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2045586
Steps to reproduce
n/a it's a race condition
Environment
We need to understand the context in which Imagecraft failed. Please let us know if you are running Imagecraft in destructive mode, whether you are using LXD or Multipass, and which operating system you are running Imagecraft on.
imagecraft.yaml
Log output
See: https://github.com/canonical/imagecraft/actions/runs/23426535878/job/68143721209?pr=289#step:9:196
Getting partition table
Adding partition volume/pc/data3 to the image
Setting up GRUB in the image
mount: /home/imagecraft/tests/spread/pack/complex/mount: special device /dev/loop7p2 does not exist.
dmesg(1) may have more information after failed mount system call.
mount: /home/imagecraft/tests/spread/pack/complex/mount: mount failed: Unknown error 5005.
Failed to clean chroot
Detailed information: Command '['/bin/mount', '/home/imagecraft/tests/spread/pack/complex/mount', '--make-rprivate']' returned non-zero exit status 32.
Full execution log: '/root/.local/state/imagecraft/log/imagecraft-20260323-081704.190556.log'
-----
.
2026-03-23 08:17:22 Debug output for google:ubuntu-24.04-64:tests/spread/pack/complex (mar230753-821890) :
-----
++ find /root/.local/state/imagecraft/log/ -name 'imagecraft*.log'
++ sort -n
++ tail -n1
+ imagecraft_log_file=/root/.local/state/imagecraft/log/imagecraft-20260323-081704.190556.log
[...]
2026-03-23 08:17:21.218 Getting partition table
2026-03-23 08:17:21.218 Running command: ['sfdisk', '--json', 'pc.img']
2026-03-23 08:17:21.222 Adding partition volume/pc/data3 to the image
2026-03-23 08:17:21.286 Running command: ['sfdisk', '--json', 'pc.img']
2026-03-23 08:17:21.289 Setting up GRUB in the image
2026-03-23 08:17:21.289 Running command: ['losetup', '--find', '--show', '--partscan', 'pc.img']
2026-03-23 08:17:21.313 Attached image pc.img as loop device /dev/loop7
2026-03-23 08:17:21.314 [pid=57966] parent process
2026-03-23 08:17:21.314 [pid=57966] set up chroot
2026-03-23 08:17:21.314 setup chroot: PosixPath('/home/imagecraft/tests/spread/pack/complex/mount')
2026-03-23 08:17:21.314 [pid=57966] mount '/home/imagecraft/tests/spread/pack/complex/mount' on chroot
2026-03-23 08:17:21.315 mount device='/dev/loop7p2', mountpoint='/home/imagecraft/tests/spread/pack/complex/mount', args=()
2026-03-23 08:17:21.318 [pid=57966] clean up chroot
2026-03-23 08:17:21.318 cleanup chroot: PosixPath('/home/imagecraft/tests/spread/pack/complex/mount')
2026-03-23 08:17:21.318 [pid=57966] umount: '/home/imagecraft/tests/spread/pack/complex/mount'
2026-03-23 08:17:21.318 mount device='/home/imagecraft/tests/spread/pack/complex/mount', mountpoint='--make-rprivate', args=()
2026-03-23 08:17:21.321 Running command: ['losetup', '--json']
2026-03-23 08:17:21.325 Detaching loop device /dev/loop7 (from /home/imagecraft/tests/spread/pack/complex/pc.img)
2026-03-23 08:17:21.325 Running command: ['losetup', '-d', '/dev/loop7']
2026-03-23 08:17:21.327 Failed to clean chroot
2026-03-23 08:17:21.327 Detailed information: Command '['/bin/mount', '/home/imagecraft/tests/spread/pack/complex/mount', '--make-rprivate']' returned non-zero exit status 32.
2026-03-23 08:17:21.328 Full execution log: '/root/.local/state/imagecraft/log/imagecraft-20260323-081704.190556.log'
Check existing issues
Bug description
Discovered and researched by @smethnani.
When we create loop devices, there's a race condition we sometimes hit when trying to mount them before they fully exist.
The upstream version of this bug is in https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/2045586
Steps to reproduce
n/a it's a race condition
Environment
We need to understand the context in which Imagecraft failed. Please let us know if you are running Imagecraft in destructive mode, whether you are using LXD or Multipass, and which operating system you are running Imagecraft on.
imagecraft.yaml
Log output