← Back to issue list

Keep overlayfs mounted when running with --debug and something fails

View original Github issue

Metadata

Project
imagecraft
Number
#148
Type
issue
State
open
Author
toabctl
Labels
Type: Bug
Created
Updated
Closed

Current evaluation

imagecraft unmounts overlayfs before dropping into the --debug shell when an overlay-script fails, making it hard to inspect the failed state. Workaround is manual fuse-overlayfs remount. A maintainer (lengau) asked whether craft-parts should handle this, but no fix has landed.

Suggested action: keep open

Reason: The issue is a legitimate bug/feature request with a clear reproduction and a concrete workaround documented by the reporter. A maintainer (lengau) engaged on 2025-08-14 by asking whether craft-parts should handle this, indicating the issue is acknowledged and under consideration. The last activity was 382 days ago (~12.5 months), which is moderately stale, but the issue is not irrelevant — the overlay unmount behavior in craft-parts (overlay_manager.py unmount() called before the debug shell) is still present in the current codebase. The fix would likely require a small change in craft-parts to skip unmounting when --debug is active, or a callback in imagecraft to remount. This is not a support request and not stale enough to close.

Impact: 45 Quick Win: 27.0 Staleness: 55 Complexity: 40 Confidence: 70 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
qwen/qwen3.8-27b
Impact: 45
Quick Win: 27.0
Staleness: 55
Complexity: 40
Confidence: 70
Support Request: 10
keep open imagecraft unmounts overlayfs before dropping into the --debug shell when an overlay-script fails, making it hard to inspect the failed state. Workaround is manual fuse-overlayfs remount. A maintainer (lengau) asked whether craft-parts should handle this, but no fix has landed.
qwen/qwen3.6-35b-a3b
Staleness: 78
Complexity: 35
Confidence: 70
Support Request: 10
keep open Bug requesting overlayfs stay mounted when --debug triggers after a script failure. Currently inactive for over a year with no maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 35
Confidence: 60
Support Request: 10
keep open Requests keeping overlayfs mounted when --debug is active and a script fails, to aid debugging. Currently unmounts before dropping to shell. Inactive for over a year with maintainer discussion about upstream resolution in craft-parts.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 45
Confidence: 60
Support Request: 10
needs triage Overlayfs is unmounted before dropping into a debug shell when an overlay-script fails, hindering debugging. Issue is untriaged and inactive for over 10 months.
qwen3.6-35b-a3b-mtp-q6
Staleness: 75
Complexity: 45
Confidence: 80
Support Request: 10
needs triage overlayfs unmounts before dropping into debug shell on script failure, hindering debugging. Request to keep it mounted. Open, awaiting triage or cross-project resolution in craft-parts.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.