fix: Make mounted devices private before recursively unmounting the chroot
Metadata
Current evaluation
Merged fix that remounts chroot devices as private before recursive unmounting to properly handle submounts. Resolves #1344. Approved by reviewers and passed all CI checks.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the guidelines for contributing?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] Have you successfully run `make lint && make test`?
- [x] Have you added an entry to the changelog (`docs/reference/changelog.rst`)?
---
When cleaning the chroot, before unmounting mounted devices, remount them as recursively private. Also recursively umount every device to account for submounts added by package installation.
Manually tested with Imagecraft, installing packages in the overlay with the following part:
```yaml
packages:
plugin: nil
overlay-packages:
- ubuntu-server-minimal
- grub2-common
- grub-pc
- shim-signed
- linux-image-generic
overlay-script: |
rm $CRAFT_OVERLAY/etc/cloud/cloud.cfg.d/90_dpkg.cfg
```
Also tested with Rockcraft, see https://github.com/canonical/rockcraft/pull/986
Fixes #1344
CRAFT-4804
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged fix that remounts chroot devices as private before recursive unmounting to properly handle submounts. Resolves #1344. Approved by reviewers and passed all CI checks. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Fixes chroot cleanup by remounting devices as recursively private before unmounting, preventing errors from package submounts. Resolves #1344 and CRAFT-4804. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #400 chroot: mark /dev mount as private | craft-parts | merged | Merged fix marking /dev mount as private to prevent shared mount propagation in chroots. Resolves unmount cascading caused by rootfs becoming a shared mount, addressing rockcraft#195. Approved and passed CI. | |
| #401 Release 1.18.4 | craft-parts | merged | Merged release 1.18.4 by maintainer cmatsuoka. Changes make the chroot /dev mount private. Approved by one reviewer with no unresolved comments. | |
| #1344 More robust chroot unmounting | craft-parts | closed | Closed and superseded by internal Jira ticket CRAFT-4804. No code changes were merged. The proposed --make-rprivate and --recursive unmounting fix remains unimplemented. | |
| #295 chroot: fix device nodes in overlay base image | craft-parts | merged | Merged. Replaced standard bind mounts with rbind to fix device nodes failing to appear in containers. Approved by a reviewer and passed CI checks. |