Keep overlayfs mounted when running with --debug and something fails
Metadata
Current evaluation
Overlayfs unmounts before entering the debug shell on failure, hindering troubleshooting; this bug is currently under discussion for a craft-parts implementation.
Suggested action: needs triage
Reason: The issue is a well-structured bug report with clear reproduction steps and environment details, but it lacks any maintainer assessment, assignee, or prioritization. Despite being over 9 months old, the bug remains valid and actionable. It requires maintainer triage to categorize, prioritize, or route it to the appropriate team (e.g., craft-parts) rather than leaving it unattended.
Staleness:
65
Complexity:
30
Support Request:
10
Issue body
### Bug Description
Currently the overlayfs gets unmounted before dropping into the debug shell if the overlay-script part fails. But that makes debugging a lot harder given that the environment changed compared to the state were it failed.
### To Reproduce
Eg. running:
```
CRAFT_BUILD_ENVIRONMENT=multipass imagecraft --verbosity debug pack --debug
```
this will result in output like:
```
2025-05-19 09:08:41.466 Overlaying chimg
2025-05-19 09:08:41.467 execute action chimg:Action(part_name='chimg', step=Step.OVERLAY, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2025-05-19 09:08:41.467 mount overlayfs on /root/overlay/overlay
2025-05-19 09:08:41.467 fuse-overlayfs mountpoint='/root/overlay/overlay', args=('-olowerdir=/root/parts/rootfs/layer:/root/overlay/packages:/root/bare_base_layer,upperdir=/root/parts/chimg/layer,workdir=/root/overlay/work',)unknown argument ignored: lazytime
2025-05-19 09:08:41.512 Executing PosixPath('/tmp/tmphp409_az/scriptlet.sh')
2025-05-19 09:08:41.513 :: + exit 1
2025-05-19 09:08:41.514 unmount overlayfs from /root/overlay/overlay
2025-05-19 09:08:41.514 umount mountpoint='/root/overlay/overlay', args=()
2025-05-19 09:08:41.516 'overlay-script' in part 'chimg' failed with code 1.
2025-05-19 09:08:41.516 Launching shell on build environment...
2025-05-19 09:08:41.516 Emitter: Pausing control of the terminal
imagecraft-ubuntu-minimal-amd64-236227516 ../project#
```
So `/root/overlay/overlay` is no longer mounted so I can't easily rerun/debug the command from the `overlay-script` section.
### Environment
* ubuntu 25.04 on amd64
* imagecraft from latest/edge channel
### imagecraft.yaml
```shell
name: ubuntu-minimal
version: "0.1"
base: bare
build-base: ubuntu@22.04
platforms:
amd64:
volumes:
pc:
schema: gpt
structure:
- name: efi
type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
filesystem: vfat
role: system-boot
filesystem-label: UEFI
size: 256M
- name: rootfs
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
filesystem: ext4
filesystem-label: writable
role: system-data
size: 5G
parts:
# build a simple rootfs
rootfs:
plugin: nil
build-packages:
- "mmdebstrap"
overlay-script: |
mmdebstrap --arch $CRAFT_ARCH_BUILD_FOR \
--mode=sudo \
--format=dir \
--include=ca-certificates,ubuntu-pro-client \
--variant=minbase \
--include=apt \
jammy \
$CRAFT_OVERLAY/
mkdir $CRAFT_OVERLAY/boot/efi
# add packages using chroot and apt to have maintainer scripts properly run
chimg:
plugin: dump
source: .
source-type: local
after: [rootfs]
overlay-script: |
# THIS FAILS SO I WANT TO HAVE THE OVERLAY MOUNTED WHEN DROPPING INTO THE DEBUG SHELL
exit 1
# fix fstab and organize content to the partition
fstab:
plugin: nil
after: [chimg]
overlay-script: |
cat << EOF > $CRAFT_OVERLAY/etc/fstab
LABEL=writable / ext4 discard,errors=remount-ro 0 1
LABEL=UEFI /boot/efi vfat umask=0077 0 1
EOF
mv $CRAFT_OVERLAY/* $CRAFT_VOLUME_PC_ROOTFS_OVERLAY/
```
### Relevant log output
```shell
2025-05-19 09:08:41.466 Overlaying chimg
2025-05-19 09:08:41.467 execute action chimg:Action(part_name='chimg', step=Step.OVERLAY, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
2025-05-19 09:08:41.467 mount overlayfs on /root/overlay/overlay
2025-05-19 09:08:41.467 fuse-overlayfs mountpoint='/root/overlay/overlay', args=('-olowerdir=/root/parts/rootfs/layer:/root/overlay/packages:/root/bare_base_layer,upperdir=/root/parts/chimg/layer,workdir=/root/overlay/work',)unknown argument ignored: lazytime
2025-05-19 09:08:41.512 Executing PosixPath('/tmp/tmphp409_az/scriptlet.sh')
2025-05-19 09:08:41.513 :: + exit 1
2025-05-19 09:08:41.514 unmount overlayfs from /root/overlay/overlay
2025-05-19 09:08:41.514 umount mountpoint='/root/overlay/overlay', args=()
2025-05-19 09:08:41.516 'overlay-script' in part 'chimg' failed with code 1.
2025-05-19 09:08:41.516 Launching shell on build environment...
2025-05-19 09:08:41.516 Emitter: Pausing control of the terminal
imagecraft-ubuntu-minimal-amd64-236227516 ../project#
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| 2026-06-01 12:35:46.834349+00:00 | qwen3.6-35b-moe-q4 |
Staleness:
65
Complexity:
30
Support Request:
10
|
needs triage | Overlayfs unmounts before entering the debug shell on failure, hindering troubleshooting; this bug is currently under discussion for a craft-parts implementation. |
| 2026-06-01 12:32:10.003133+00:00 | pending | — | — | — |