Rename existing BLS entry with the new machine-id
This change replaces the call to grub2-switch-to-blscfg with a file rename to update it to the actual machine-id. grub2-switch-to-blscfg has issues in some build environments: - When the build host is EFI boot, it assumes the image is, and fails when config file /etc/grub2-efi.cfg is missing - With recent cento9 images and a fedora build host it fails with: grub2-probe: error: cannot find a device for / (is /dev mounted?) Change-Id: I74ad800b702f2b491d958555cef8d7c7f63d74ac
This commit is contained in:
parent
3df51c5279
commit
0d0f7f8075
@ -13,34 +13,20 @@ fi
|
||||
# This is a workaround for the grub issue reported upstream with
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2032680
|
||||
|
||||
# This clears out and recreates 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.
|
||||
# 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.
|
||||
|
||||
# All grub2-switch-to-blscfg really does is call "kernel-install" with
|
||||
# the kernels installed in /lib/modules -- this is another option for
|
||||
# recreating the BLS entries. You can also re-install the kernel
|
||||
# packages to do this. Another option again would be just to rename
|
||||
# the exsiting .conf files.
|
||||
pushd /boot/loader/entries
|
||||
|
||||
# If this is already set, grub2-switch-to-blscfg will abort
|
||||
sed -i 's/GRUB_ENABLE_BLSCFG=true//' /etc/default/grub
|
||||
echo "--- /etc/default/grub dump ---"
|
||||
cat /etc/default/grub
|
||||
machine_id=$(</etc/machine-id)
|
||||
|
||||
# Clear out the entries that came with the qcow2 image
|
||||
echo "--- Clearing BLS entries ---"
|
||||
ls /boot/loader/entries/*.conf
|
||||
rm /boot/loader/entries/*.conf
|
||||
for entry in *; do
|
||||
new_entry=$(echo $entry | sed "s/^[a-f0-9]*/$machine_id/")
|
||||
echo "renaming $entry to $new_entry for new machine-id"
|
||||
mv $entry $new_entry
|
||||
done
|
||||
popd
|
||||
|
||||
# This will regenerate /boot/loader/entries for the current
|
||||
# machine-id. After this, grub2-mkconfig works as usual.
|
||||
#
|
||||
grub2-switch-to-blscfg
|
||||
echo "--- Show kernels ---"
|
||||
grubby --info=ALL
|
||||
|
||||
# Local variables:
|
||||
# mode: sh
|
||||
# End:
|
||||
|
Loading…
Reference in New Issue
Block a user