mmdebstrap plugin leaves /sys mounted when packages trigger mount-busy during bootstrap on EFI hosts
Metadata
Current evaluation
Fixed by merged canonical/imagecraft#351 (commit d19c950), adding cleanup for lingering mmdebstrap mounts under sys and proc after bootstrap.
Resolution: closed resolved
Reason: PR canonical/imagecraft#351 was merged to unmount lingering mounts left by mmdebstrap, resolving the EFI-host /sys mount failure.
Evaluated by: mr-cal-bot
No scores available.
Issue body
## Description
When `mmdebstrap-packages` includes a package whose postinst script accesses `/sys/firmware/efi/efivars` (e.g. `grub-pc`), the plugin leaves `/sys` mounted inside `$CRAFT_PART_INSTALL` after the build step completes, causing the subsequent organize step to fail.
## Root cause
`mmdebstrap --mode=root` bind-mounts the host's `/sys` into the chroot. On EFI hosts, this includes the `efivarfs` submount at `/sys/firmware/efi/efivars`. When `grub-pc`'s postinst runs inside the chroot and accesses efivars, that submount becomes busy. mmdebstrap then emits `W: umount /sys failed: 8192` and exits successfully despite the leftover mount.
The plugin's `get_build_commands` cleans up `/dev/*` and apt state after mmdebstrap, but does not clean up leftover pseudo-filesystem mounts. When craft-parts' organize step subsequently tries to move `$CRAFT_PART_INSTALL/sys` into the overlay it fails with `shutil.Error: [Errno 5] / [Errno 13]` errors from the live sysfs.
## Steps to reproduce
On an EFI host, use the mmdebstrap plugin with `grub-pc` in `mmdebstrap-packages`:
```yaml
parts:
rootfs:
plugin: mmdebstrap
mmdebstrap-packages:
- grub-pc
organize:
"*": (overlay)/
```
## Error
```
W: umount /sys failed: 8192
...
shutil.Error: [('/path/to/parts/rootfs/install/sys/kernel/mm/hugepages/...', ..., '[Errno 5] Input/output error'), ...]
```
## Workaround
Do not use `mmdebstrap-packages` for packages that run `grub-install` during postinst. Install those via `overlay-packages` in a separate `nil` part instead, where craft-parts manages chroot mount lifetime.
## Suggested fix
Add lazy-unmount cleanup for pseudo-filesystems to `get_build_commands`, after the mmdebstrap invocation:
```python
'umount -lf "$CRAFT_PART_INSTALL/sys/firmware/efi/efivars" 2>/dev/null || true',
'umount -lf "$CRAFT_PART_INSTALL/sys" 2>/dev/null || true',
'umount -lf "$CRAFT_PART_INSTALL/proc" 2>/dev/null || true',
'umount -lf "$CRAFT_PART_INSTALL/dev/pts" 2>/dev/null || true',
'umount -lf "$CRAFT_PART_INSTALL/dev" 2>/dev/null || true',
```
This is safe because mmdebstrap should have already unmounted these; the commands are no-ops if it succeeded cleanly.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged canonical/imagecraft#351 (commit d19c950), adding cleanup for lingering mmdebstrap mounts under sys and proc after bootstrap. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR canonical/imagecraft#351 (commit d19c950): mmdebstrap_plugin's cleanup now findmnt-recursively lazy-unmounts leftovers under $CRAFT_PART_INSTALL and clears sys/proc/dev. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR canonical/imagecraft#351, which cleans up lingering mounts left by mmdebstrap on EFI hosts. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without implementation. Maintainers discussed recursive unmounting strategies to handle leftover pseudo-filesystem mounts during mmdebstrap bootstrap on EFI hosts, but no fix was merged. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed after discussion. No fix merged; workaround provided. Contributors discussed recursive unmount approaches for future implementation. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without a fix. Maintainers discussed recursive lazy-unmount cleanup for $CRAFT_PART_INSTALL to resolve leftover pseudo-filesystem mounts during EFI bootstrap, referencing patterns from curtin and livefs-editor. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed and tracked as IMAGECRAFT-142. The bug leaves /sys mounted during EFI bootstrap, breaking the organize step. Resolution involves recursive unmount cleanup for $CRAFT_PART_INSTALL, referencing implementations in curtin and livefs-editor. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/imagecraft#351
(confidence 100%)
Merged as commit d19c950 and explicitly fixes #337.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #351 fix(mmdebstrap_plugin): unmount lingering mounts | imagecraft | merged | PR #351 merged as commit d19c950, fixing #337 by unmounting lingering mmdebstrap mounts and cleaning sys/* and proc/* contents. |