From 59020e9560ec2fdfb11bb7dae44f5855322e7289 Mon Sep 17 00:00:00 2001 From: Andrew Lukoshko Date: Fri, 13 Mar 2026 00:16:44 +0000 Subject: [PATCH] Fix BLS entries not corrected before grub2-mkconfig on RHEL 8 --- ...-not-corrected-before-grub2-mkconfig.patch | 67 +++++++++++++++++++ SPECS/kiwi.spec | 5 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0004-Fix-BLS-entries-not-corrected-before-grub2-mkconfig.patch diff --git a/SOURCES/0004-Fix-BLS-entries-not-corrected-before-grub2-mkconfig.patch b/SOURCES/0004-Fix-BLS-entries-not-corrected-before-grub2-mkconfig.patch new file mode 100644 index 0000000..a5bf0b3 --- /dev/null +++ b/SOURCES/0004-Fix-BLS-entries-not-corrected-before-grub2-mkconfig.patch @@ -0,0 +1,67 @@ +From 881bb46fcbefac0be9e7540b078a4dbe4f0f5891 Mon Sep 17 00:00:00 2001 +From: Andrew Lukoshko +Date: Fri, 13 Mar 2026 01:12:40 +0100 +Subject: [PATCH] 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-... +--- + kiwi/bootloader/config/grub2.py | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/kiwi/bootloader/config/grub2.py b/kiwi/bootloader/config/grub2.py +index 58f0c6e5..58568755 100644 +--- a/kiwi/bootloader/config/grub2.py ++++ b/kiwi/bootloader/config/grub2.py +@@ -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'}) +-- +2.43.7 + diff --git a/SPECS/kiwi.spec b/SPECS/kiwi.spec index 819815c..6322add 100644 --- a/SPECS/kiwi.spec +++ b/SPECS/kiwi.spec @@ -26,6 +26,8 @@ Patch0001: 0001-run-grub-mkconfig-with-os-prober-disable.patch Patch0002: 0002-Fixed-missing-selinux-context-setup-for-live-ISOs.patch ## From https://git.almalinux.org/almalinux/kiwi-el8/commit/f5799d404d79476ffce6253a7ab7fbe510f4673e Patch0003: 0003-Backport-zipl-bootloader-support-from-upstream-kiwi.patch +## From https://git.almalinux.org/almalinux/kiwi-el8/commit/881bb46fcbefac0be9e7540b078a4dbe4f0f5891 +Patch0004: 0004-Fix-BLS-entries-not-corrected-before-grub2-mkconfig.patch # Fedora-specific patches ## Use buildah instead of umoci by default for OCI image builds @@ -575,8 +577,9 @@ done # Empty metapackage %changelog -* Fri Mar 13 Andrew Lukoshko - 9.25.22-2 +* Fri Mar 13 2026 Andrew Lukoshko - 9.25.22-2 - Backport zipl bootloader support from upstream kiwi v10 +- Fix BLS entries not corrected before grub2-mkconfig on RHEL 8 * Thu Mar 12 2026 Neal Gompa - 9.25.22-1 - Update to 9.25.22