diskimage-builder/diskimage_builder/elements/bootloader
Ian Wienand 2d47d4157c Fix BLS based bootloader installation
This reverts I2701260d54cf6bc79f1ac765b512d99d799e8c43,
Idf2a471453c5490d927979fb97aa916418172153 and part of
Iecf7f7e4c992bb23437b6461cdd04cdca96aafa6 which added special flags to
update kernels via grubby.

These changes actually ended up reverting the behaviour on Fedora 35,
which is what led me to investigate what was going on more fully.

All distros still support setting GRUB_DEVICE in /etc/default/grub;
even the BLS based ones (i.e. everything !centos7).

The implementation *is* confusing -- in earlier distros each BLS entry
would refer to the variable $kernelopts; which grub2-mkconfig would
write into /boot/grub2/grubenv.  After commit [1] this was reverted,
and the kernel options are directly written into the BLS entry.

But the real problem is this bit from [2]

 get_sorted_bls()
 {
     if ! [ -d "${blsdir}" ] || ! [ -e /etc/machine-id ]; then
        return
     fi
     ...
     files=($(for bls in ${blsdir}/${machine_id}-*.conf; do
     ...
 }

i.e., to avoid overwriting BLS entries for other OS-boots (?),
grub2-mkconfig will only update those BLS entries that match the
current machine-id.

The problem for DIB is that we are clearing the machine-id early in
finalise.d/01-clear-machine-id, but then running the bootloader update
later in finalise.d/50-bootloader.

The result is that the bootloader entry generated when we installed
the kernel (which guessed at the root= device, etc.) is *not* updated.
Even more annoyingly, the gate doesn't pick this up -- because the
gate tests run on a DIB image that was booted with
"root=LABEL=cloudimg-rootfs" the kernel initially installed with
"install-kernel" (that we never updated) is actually correct.  But
this fails when built on a production host.

Thus we don't need any of the explicit grubby updates; these are
reverted here.  This moves the machine-id clearing to after the
bootloader setup, which allows grub2-mkconfig to setup the BLS entries
correctly.

[1] 4a742183a3?branch=master
[2] https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0062-Add-BLS-support-to-grub-mkconfig.patch

Depends-On: https://review.opendev.org/c/zuul/nodepool/+/818705
Change-Id: Ia0e49980eb50eae29a5377d24ef0b31e4d78d346
2021-11-25 14:26:23 +11:00
..
environment.d update grub cmdline to current kernel parameters 2020-06-14 00:39:42 -05:00
finalise.d Fix BLS based bootloader installation 2021-11-25 14:26:23 +11:00
README.rst bootloader: remove extlinux/syslinux path 2021-05-13 10:33:06 +10:00
pkg-map RHEL/Centos 9 does not have package grub2-efi-x64-modules 2021-09-13 09:32:53 +12:00

README.rst

bootloader

Installs grub[2] on boot partition on the system.

Arguments

  • DIB_GRUB_TIMEOUT sets the grub menu timeout. It defaults to 5 seconds. Set this to 0 (no timeout) for fast boot times.
  • DIB_BOOTLOADER_DEFAULT_CMDLINE sets parameters that are appended to the GRUB_CMDLINE_LINUX_DEFAULT values in grub.cfg configuration. It defaults to nofb nomodeset gfxpayload=text.
  • DIB_BOOTLOADER_SERIAL_CONSOLE sets the serial device to be used as a console. It defaults to hvc0 for PowerPC, ttyAMA0,115200 for ARM64, otherwise ttyS0,115200.