Skip to content

container-export: Handle metacopy=off overlay setups#2097

Open
cgwalters wants to merge 1 commit intobootc-dev:mainfrom
cgwalters:metacopy
Open

container-export: Handle metacopy=off overlay setups#2097
cgwalters wants to merge 1 commit intobootc-dev:mainfrom
cgwalters:metacopy

Conversation

@cgwalters
Copy link
Collaborator

This fixes a bug in container export on overlayfs setups with metacopy=off (a common setup). In that scenario we will see a single mountpoint, but different device+inode.

Change hardlink tracking to account for device+inode.

Assisted-by: OpenCode (Claude Opus 4)

This fixes a bug in `container export` on overlayfs setups with
`metacopy=off` (a common setup). In that scenario we will see
a single mountpoint, but different device+inode.

Change hardlink tracking to account for device+inode.

Assisted-by: OpenCode (Claude Opus 4)
Signed-off-by: Colin Walters <walters@verbum.org>
@bootc-bot bootc-bot bot requested a review from jmarrero March 26, 2026 16:37
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the hardlink tracking logic in container_export.rs to use a combination of device ID and inode number as the key, rather than just the inode. This change accommodates overlay filesystems where device numbers may differ between directories and files. Additionally, the explicit check for an expected device ID has been removed. I have no feedback to provide.

let filename_path = Path::new(filename);
let metadata = dir.metadata(filename_path)?;

// Skip files on different devices (e.g., bind mounts in containers like /etc/hosts).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that now we would start including the bind-mounted /etc/hosts when we export?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it does.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As documented, this expects the image as a separate mount point:

podman run --rm \
    --mount=type=image,source=quay.io/example/example,target=/run/target \
    quay.io/example/example \
    bootc container export --kernel-in-boot /run/target > example.tar

And in that case, there won't be any container runtime injected content like /etc/hosts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants