rhel: work around RHEL-9 BLS issues
Similar to the CentOS-9-Stream fix [1] this change renames the default BLS entry to match the current machine-id so that grub2-mkconfig calls will refresh the kernel options. However there is an additional issue with the rhel-9 base image. It is unique in having a dedicated boot partition, so the path to the kernel and initramfs don't include /boot. This results in an unbootable image when /boot is a directory of the root partition. These paths do not get corrected by calling grub2-mkconfig, so this change performs a sed on the paths to fix them for a root partition /boot. [1] I327f5e7a95e47905c01138c8c4483f3f03e8efff Change-Id: I37a1d310e1854f4a49725e355d484e456ea4fc7a
This commit is contained in:
parent
f44644f20f
commit
4376f66407
39
diskimage_builder/elements/rhel/pre-install.d/03-reset-bls-entries
Executable file
39
diskimage_builder/elements/rhel/pre-install.d/03-reset-bls-entries
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
echo "--- Show kernels ---"
|
||||||
|
grubby --info=ALL
|
Loading…
Reference in New Issue
Block a user