From f118649738de16b78436139e427e5743c94d3b9f Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 21 Jun 2022 14:01:08 +1200 Subject: [PATCH] Fix BLS entries for /boot partitions Creating a separate /boot partition is desirable in some cases[1]. This change detects if /boot is a partition, and ensures that the kernel/ramdisk paths are correct in either case. This is applied to all BLS entries files, whether they were generated by the previous grub2-mkconfig call or in the source image. This means the rhel9 specific workaround can be removed since all paths are now normalised at this stage. [1] https://review.opendev.org/c/openstack/tripleo-image-elements/+/846807 Change-Id: I62120ec8c65876e451532d2654d37435eb3606a6 Resolves: rhbz#2101514 --- .../bootloader/finalise.d/50-bootloader | 23 +++++++++++++++++++ .../rhel/post-install.d/03-reset-bls-entries | 5 ---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader index 3b451d02..3e243325 100755 --- a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader +++ b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader @@ -156,6 +156,29 @@ if [[ ${DIB_BLOCK_DEVICE} == "efi" ]]; then fi fi +# Ensure paths in BLS entries account for /boot being a partition or part of the +# root partition +if [[ -e /boot/loader/entries ]]; then + pushd /boot/loader/entries + set +e + mountpoint /boot + bootmount=$? + + for entry in *; do + if [[ $bootmount -eq 0 ]]; then + sed -i "s| /boot/vmlinuz| /vmlinuz|" $entry + sed -i "s| /boot/initramfs| /initramfs|" $entry + else + sed -i "s| /vmlinuz| /boot/vmlinuz|" $entry + sed -i "s| /initramfs| /boot/initramfs|" $entry + fi + done + set -e + popd + # Print resulting grubby output for debug purposes + grubby --info=ALL +fi + if [[ ! "$ARCH" =~ "ppc" ]] && [[ -z "${DIB_BLOCK_DEVICE}" ]]; then echo "WARNING: No bootloader installation will occur." echo "To install a bootloader ensure you have included a block-device-* element" diff --git a/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries b/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries index d2bd4f6d..d4d5df5f 100755 --- a/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries +++ b/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries @@ -27,11 +27,6 @@ for entry in *.conf; do if [[ $entry != $new_entry ]]; then mv $entry $new_entry fi - - # RHEL-9 is unique in having a separate /boot partition, fix the paths to assume - # /boot will be in the root partition. - sed -i "s| /vmlinuz| /boot/vmlinuz|" $new_entry - sed -i "s| /initramfs| /boot/initramfs|" $new_entry done popd