Skip to content

UKI Cleanup#2200

Open
Johan-Liebert1 wants to merge 6 commits into
bootc-dev:mainfrom
Johan-Liebert1:uki-cleanup
Open

UKI Cleanup#2200
Johan-Liebert1 wants to merge 6 commits into
bootc-dev:mainfrom
Johan-Liebert1:uki-cleanup

Conversation

@Johan-Liebert1
Copy link
Copy Markdown
Collaborator

ukify: Allow passing custom kernel, initramfs

While building a sealed UKI image we'd want to remove the original
kernel + initramfs from the final image and have only the final UKI
present. This was not possible before as bootc container ukify
expected kernel + initramfs to be present in usr/lib/modules of
container root

Fixes: #2185


dockerfile/uki: Rework to remove kernel + initrd

Now that we can pass kernel and initrd paths to bootc ukify, rework
our UKI Dockerfile to remove kernel + initrd from the final layer
and only keep the UKI

This still will not remove the kernel + initrd from the tarball but
have whiteout instead

See #2027 (comment)


test/integration: Test vmlinuz non-existence with UKI

vmlinuz and intrd should not be present in UKI images; add test for the
same

@Johan-Liebert1 Johan-Liebert1 requested a review from cgwalters May 15, 2026 07:22
@Johan-Liebert1 Johan-Liebert1 added the ci/merge Run full CI suite (all OSes) — equivalent to merge queue label May 15, 2026
Copy link
Copy Markdown
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 refactors the UKI (Unified Kernel Image) build process to support passing explicit kernel and initramfs paths via CLI arguments, reducing reliance on auto-discovery within the rootfs. Key changes include updating the seal-uki and finalize-uki scripts to use named arguments, modifying Dockerfile stages to extract and clean up kernel components, and extending the Rust library and CLI to handle the new parameters. Review feedback identified a potential path resolution bug in the Rust file existence checks, a filename mismatch in the upgrade test Dockerfile, and suggested improvements for error handling and validation in the seal-uki script.

Comment thread crates/lib/src/ukify.rs Outdated
Comment thread tmt/tests/Dockerfile.upgrade Outdated
Comment thread contrib/packaging/seal-uki Outdated
@github-actions github-actions Bot added the area/documentation Updates to the documentation label May 15, 2026
@Johan-Liebert1 Johan-Liebert1 force-pushed the uki-cleanup branch 7 times, most recently from 66dc0e3 to 3a9dc2b Compare May 18, 2026 10:09
cat >> /tmp/Containerfile.drop-lbis <<-EOF
FROM base as kernel
RUN <<-RUNEOF
objcopy -O binary --only-section=.initrd /boot/EFI/Linux/*.efi /boot/initramfs.img
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We were discussing maybe having this in bootc - bootc internals uki extract?

Comment thread tmt/plans/integration.fmf
how: fmf
test:
- /tmt/tests/tests/test-37-install-no-boot-dir
extra-fixme_skip_if_composefs: true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How is this related?

From live chat - we probably want to test at a basic level that composefs tests actually install that way

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh, this is failing for another reason. I kinda lumped it with the bootloader=none one

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually this is failing for composefs because bootloader=none is not supported for composefs and this test fails when trying to install bootloader for composefs. For ostree, the bootloader installation is simply skipped with bootloader=none

I did end up fixing a containers-storage permission issue while debugging this

Comment thread crates/lib/src/bootc_composefs/status.rs Outdated
Comment thread crates/lib/src/bootc_composefs/status.rs Outdated
RUN --network=none --mount=type=tmpfs,target=/run --mount=type=tmpfs,target=/tmp \
--mount=type=bind,from=sealed-uki,src=/,target=/run/sealed-uki \
/usr/bin/finalize-uki /run/sealed-uki/out
cat >> /tmp/Containerfile.drop-lbis <<-EOF
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This isn't about dropping lbis?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is kinda confusing but the original Dockerfile is for removing lbis and we just append UKI stuff to it

Comment thread Dockerfile
Comment on lines +276 to +280
kver=$(bootc container inspect --rootfs /run/base-penultimate-src --json | jq -r '.kernel.version')

rm -v "/usr/lib/modules/$kver/vmlinuz"
rm -v "/usr/lib/modules/$kver/initramfs.img"
fi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this one would end up being closer to user-facing, I would prefer to streamline this more.

I think what would work best is to have our "base" build process be a stage that generates a single intermediate image with /rootfs and /kernel or so. This could be part of bootc-base-imagectl, or we could have it be part of something more like bootc container split-root-and-uki?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sgtm. By the "base" build process, are you referring to the Dockerfile (in bootc) or is it about something else?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The pattern we apply to this should generalize to https://github.com/cgwalters/rhel-bootc-examples/tree/sealed/sealing as well etc.

@travier
Copy link
Copy Markdown
Contributor

travier commented May 20, 2026

I think we should have the kernel and initrd as required arguments and thus only support the case where they are not in the rootfs anymore as I don't see a use case where someone would want a sealed image with both a UKI and split out kernel and initrd.

Edit: That would break the current bootc container ukify signature but I don't think we've declared it stable yet?

@cgwalters
Copy link
Copy Markdown
Collaborator

Hmm. I kind of lean towards not breaking it at least right away, it seems really easy to continue to support what we have now too. We could mark it deprecated though.

Comment thread tmt/tests/booted/test-install-to-filesystem-var-mount.sh Outdated
@travier
Copy link
Copy Markdown
Contributor

travier commented May 21, 2026

Failures are transient & volatile related. Maybe from #2201?

@github-actions github-actions Bot added area/install Issues related to `bootc install` area/ostree Issues related to ostree labels May 28, 2026
While building a sealed UKI image we'd want to remove the original
kernel + initramfs from the final image and have only the final UKI
present. This was not possible before as `bootc container ukify`
expected kernel + initramfs to be present in `usr/lib/modules` of
container root

Fixes: bootc-dev#2185

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>

Mark `bootc container ukify` without `--kernel` and `--initramfs` as
deprecated
Now that we can pass kernel and initrd paths to `bootc ukify`, rework
our UKI Dockerfile to remove kernel + initrd from the final layer
and only keep the UKI

This still will not *remove* the kernel + initrd from the tarball but
have whiteout instead

See bootc-dev#2027 (comment)

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
vmlinuz and intrd should not be present in UKI images; add test for the
same

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Bootloader set to none is not supported with the composefs backend so we
skip tests with this option for composefs backend

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
We were defaulting to unprivileged user "nobody" when pulling an image,
but pulling from containers-storage was failing as it requires extra
privileges. Default to the current user, usually root, when pulling from
containers-storage

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
@Johan-Liebert1
Copy link
Copy Markdown
Collaborator Author

Johan-Liebert1 commented May 28, 2026

Hmm. I kind of lean towards not breaking it at least right away, it seems really easy to continue to support what we have now too. We could mark it deprecated though.

Don't know if clap has a way to do this, if it does I couldn't find it. We just print our custom warning if --kernel and --initramfs are not passed in

Baseconfigs tests were failing in CI because the initrd which had the
expected baseconfigs was being deleted in the same layer it was being
created in. Move the deletion to a completely separate layer

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Comment thread crates/lib/src/cli.rs
}),

(None, None) => {
eprintln!(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am having second thoughts, it should not be too onerous for us to just continue to support what we shipped before. I think we can drop the eprintln!

Comment thread crates/lib/src/cli.rs

/// Path to the kernel
#[clap(long, requires = "initramfs", requires = "kver")]
kernel: Option<Utf8PathBuf>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What I am thinking here is we could make this --kernel-dir which is defined to be a path to something like /usr/lib/modules/$kver.

That solves three problems:

  • We expect kernel+initramfs in one place, so we don't need separate args for them
  • We also require the directory to be named the same as a modules dir, so we don't need a separate kver argument

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

Labels

area/documentation Updates to the documentation area/install Issues related to `bootc install` area/ostree Issues related to ostree ci/merge Run full CI suite (all OSes) — equivalent to merge queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework UKI generation to enable removing kernel & initrd from image

3 participants