Skip to content

Run grub2-install inside the install chroot to use target image's modules#762

Open
vinceaperri wants to merge 4 commits into
mainfrom
user/vinceaperri/ic-container-systemd-udev
Open

Run grub2-install inside the install chroot to use target image's modules#762
vinceaperri wants to merge 4 commits into
mainfrom
user/vinceaperri/ic-container-systemd-udev

Conversation

@vinceaperri

@vinceaperri vinceaperri commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Image Customizer installs the legacy (BIOS) bootloader by running grub2-install on the build host, which copies grub modules from the host's grub2-pc into the target image. When the host's grub differs from the target's grub, the copied modules don't match the grub.cfg the target's own grub2-mkconfig produces, and the image fails to boot. Concretely, the AZL3-based IC container building an AZL4 image produces a disk whose grub.cfg does insmod blscfg while /boot/grub2/i386-pc/ was populated from AZL3 (no BLS modules), so it errors with file '.../blscfg.mod' not found on boot.

Fix

Install the legacy bootloader from the target's own grub2-install, run inside the install chroot, so the bootloader and its modules always come from the target. Behavior when the target does not ship grub2-pc:

Target distro version Behavior
grub2-pc present (any version) Run grub2-install in the chroot (modules come from the target).
AZL2 / AZL3 (out of preview), no grub2-pc Fall back to the host's grub2-install with a warning — preserves the existing behavior for images whose configs predate this requirement.
AZL4+ (preview), no grub2-pc Fail with a clear error telling the user to add grub2-pc to os.packages.install.

Container: explicitly install systemd-udev

The IC container's host-side disk setup calls udevadm settle (waitForDevicesToSettle). udevadm is provided by the systemd-udev package, which until now arrived only transitively via grub2. systemd-udev is now listed explicitly in imagecustomizer.Dockerfile so udevadm can never silently disappear if the grub2 dependency changes.

Testing

  • Functional: TestCustomizeImagePartitionsLegacy exercises the chroot path (config installs grub2-pc); TestCustomizeImagePartitionsLegacy_TargetMissingGrub2Pc exercises the no-grub2-pc path across AZL2/3/4 — asserting success + a valid legacy image for AZL2/3 (host fallback) and a grub2-pc error for AZL4.
  • VM tests: test_legacy_bootloader_reset_azl{2,3,4} boot a hard-reset legacy image built with grub2-pc (chroot path); test_legacy_bootloader_reset_fallback_azl{2,3} boot one built without it (host fallback).

Docs

storage.md documents the new bootType: legacy behavior and the grub2-pc requirement.

@vinceaperri vinceaperri requested a review from a team as a code owner June 5, 2026 16:16
@vinceaperri vinceaperri force-pushed the user/vinceaperri/ic-container-systemd-udev branch from 3ce1163 to a6822a5 Compare June 5, 2026 16:23
cwize1
cwize1 previously approved these changes Jun 5, 2026
@vinceaperri vinceaperri changed the title Restore systemd-udev in IC container to fix vmtest udevadm regression Run grub2-install inside the install chroot to use target image's modules Jun 5, 2026
@vinceaperri vinceaperri force-pushed the user/vinceaperri/ic-container-systemd-udev branch from a7a0f03 to 74dda02 Compare June 5, 2026 18:59
@vinceaperri vinceaperri requested a review from Copilot June 5, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR changes legacy (BIOS) bootloader installation to run grub2-install inside the target image’s install chroot so it uses the target image’s GRUB modules instead of the build host’s.

Changes:

  • Run grub2-install via shell.NewExecBuilder(...).Chroot(...) (and drop the host-side grub-install fallback).
  • Update legacy boot functional test config to install grub2-pc into the target image and adjust the test to use base-image RPM repos.
  • Remove GRUB packages from the Image Customizer container and update host prerequisite documentation / CI package lists accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
toolkit/tools/pkg/imagecustomizerlib/versionsOfToolDependencies.go Stops logging host-side grub-install version since GRUB install is no longer host-executed.
toolkit/tools/pkg/imagecustomizerlib/testdata/legacyboot-config.yaml Ensures grub2-pc is installed in the target image for legacy boot tests.
toolkit/tools/pkg/imagecustomizerlib/customizepartitions_test.go Switches legacy test flow to use base-image RPM repos so the new package install succeeds.
toolkit/tools/imagegen/installutils/installutils.go Runs grub2-install inside the install chroot to use target-image modules.
toolkit/tools/imagecustomizer/container/imagecustomizer.Dockerfile Removes GRUB packages and adds systemd-udev to satisfy udev tooling needs.
toolkit/tools/imagecustomizer/container/build-container.sh Drops arm64-only Dockerfile patching that is no longer needed after GRUB removal.
docs/imagecustomizer/quick-start/quick-start-binary.md Updates host prerequisite lists to remove GRUB tools/packages.
.github/workflows/tests-functional.yml Removes GRUB packages from functional-test host prerequisites (since GRUB install is now in-chroot).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread toolkit/tools/imagegen/installutils/installutils.go Outdated
Comment thread docs/imagecustomizer/quick-start/quick-start-binary.md
Comment thread toolkit/tools/imagegen/installutils/installutils.go
@vinceaperri vinceaperri force-pushed the user/vinceaperri/ic-container-systemd-udev branch from 74dda02 to 92b67f3 Compare June 10, 2026 20:38
Comment thread docs/imagecustomizer/api/configuration/storage.md Outdated
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.

4 participants