Compare commits

...

1 Commits
el8 ... el8-bls

Author SHA1 Message Date
881bb46fcb Fix BLS entries not corrected before grub2-mkconfig on RHEL 8
On RHEL 8-based distributions, grub2-mkconfig uses the
grub.d/10_linux_bls script which reads Boot Loader Specification
(BLS) entries from /boot/loader/entries/ and inlines them as
menuentry blocks directly in grub.cfg. This is different from
RHEL 9+ where grub.d/10_linux uses the blscfg command to load
BLS entries at boot time.

When kiwi builds a disk image, kernel packages are installed into
a chroot (the image root). The BLS entries created by the kernel
scriptlets at that point contain:

  - linux/initrd paths prefixed with the build host's image root
    path (e.g. /var/tmp/kiwi-build/build/image-root/boot/vmlinuz-...)
  - an options line from the build host's /proc/cmdline

Previously, kiwi corrected these BLS entries only *after* running
grub2-mkconfig. On RHEL 9+ this works fine because grub.cfg just
contains blscfg and reads the (now corrected) BLS entries at boot
time. On RHEL 8, however, grub2-mkconfig had already inlined the
*uncorrected* BLS entries into grub.cfg, resulting in wrong kernel
paths and boot options that caused the image to fail to boot.

This commit adds calls to _fix_grub_loader_entries_boot_cmdline()
and _fix_grub_loader_entries_linux_and_initrd_paths() before
grub2-mkconfig, so that BLS entries are corrected before they get
inlined into grub.cfg. The existing post-grub2-mkconfig calls are
retained because grub2-mkconfig itself may re-create or modify BLS
entries on some distributions.

Fixes boot failure on AlmaLinux 8 ppc64le GenericCloud images built
with kiwi where grub.cfg contained build-root paths like:
  linux /var/tmp/kiwi-build/build/image-root/boot/vmlinuz-4.18.0-...
instead of:
  linux /vmlinuz-4.18.0-...
2026-03-13 01:12:40 +01:00

View File

@ -281,6 +281,16 @@ class BootLoaderConfigGrub2(BootLoaderConfigBase):
self.boot_directory_name, 'grub.cfg'
]
)
# Fix BLS entries before running grub2-mkconfig. On RHEL 8
# the grub.d/10_linux_bls script reads BLS entries and inlines
# them as menuentry blocks in grub.cfg rather than emitting a
# blscfg command. BLS entries created during package install in
# the kiwi image root contain the build host path prefix in
# linux/initrd paths and the host /proc/cmdline in options.
# Those must be corrected before grub2-mkconfig reads them.
self._fix_grub_loader_entries_boot_cmdline()
self._fix_grub_loader_entries_linux_and_initrd_paths()
# Disable os-prober, it takes information from the host it
# runs on which is not necessarily matching with the image
os.environ.update({'GRUB_DISABLE_OS_PROBER': 'true'})