diskimage-builder/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries
Steve Baker f118649738 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
2022-06-28 02:41:21 +00:00

35 lines
824 B
Bash
Executable File

#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [[ ! '9' =~ ${DIB_RELEASE} ]]; then
exit 0
fi
# This is a workaround for the grub issue reported upstream with
# https://bugzilla.redhat.com/show_bug.cgi?id=2032680
# This renames the BLS entries from the upstream .qcow2 image in
# /boot/loader/entries with the current machine-id. This means that in the
# bootloader setup, grub2-mkconfig will update config options as required.
pushd /boot/loader/entries
machine_id=$(</etc/machine-id)
for entry in *.conf; do
new_entry=$(echo $entry | sed "s/^[a-f0-9]*/$machine_id/")
echo "renaming $entry to $new_entry for new machine-id"
if [[ $entry != $new_entry ]]; then
mv $entry $new_entry
fi
done
popd
echo "--- Show kernels ---"
grubby --info=ALL