Skip to content

LUKS device fails to close with Device or resource busy when bootc runs via container #22

@hanthor

Description

@hanthor

When bootc install to-filesystem runs via podman run --pid=host, the LUKS device cleanup fails.

Error:
device-mapper: remove ioctl on fisherman-root failed: Device or resource busy
cryptsetup luksClose fisherman-root: exit status 5

Root Cause:
The Cleanup.Run() function in internal/post/post.go calls luksClose immediately after unmounting, without flushing pending I/O or releasing device references that may be held after the container exits.

Solution:
Add the following cleanup steps before calling luks.Close(), mirroring the strategy in internal/disk/partition.go:unmountAll():

  1. fuser -km to kill remaining processes holding device references
  2. blockdev --flushbufs to flush pending I/O
  3. udevadm settle to wait for device-mapper to release handles

This prevents the Device or resource busy error when LUKS devices are closed after container-based installs.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions