diskimage-builder perpared rhel7.6 uefi image uses wrong grub config

Bug #1851516 reported by Inessa Vasilevskaya
This bug affects 2 people
Affects Status Importance Assigned to Milestone

Bug Description

Seen on: DIB (b846360aa664004dae9d9abf4d43e4f20cc4b87d), Fedora 29

To reproduce:

1. Base image is official Red Hat Enterprise Linux 7.6 Update KVM Guest Image (20190618)
2. Qcow2 built with `DIB_AVOID_PACKAGES_UPDATE=1 DIB_IMAGE_SIZE=10 DIB_RELEASE=7 DIB_LOCAL_IMAGE=/home/ivasilev/Downloads/rhel-server-7.6-update-5-x86_64-kvm.qcow2 REG_REPOS="rhel-7-server-optional-rpms,rhel-7-server-extras-rpms" REG_AUTO_ATTACH=true REG_USER="MYUSERHERE" REG_PASSWORD="MYPASSHERE" REG_METHOD=portal REG_RELEASE=7.6 disk-image-create -o rhel7-uefi-attempt2.qcow2 rhel vm block-device-efi`

DIB_AVOID_PACKAGES_UPDATE=1 is necessary to suppress upgrade from 7.6 to 7.7 as the goal is to end up with rhel 7.6

3. Image uploaded to openstack with `--property hw_firmware_type=uefi`
4. Boot a vm from the image, verify it successfully boots and has UEFI.
5. There will be no /boot/efi/EFI/redhat/grub.cfg present (symlink /etc/grub2-efi.cfg broken as well),
any attempts to generate the config with grub2-mkconfig -0 /boot/efi/EFI/redhat/grub.cfg won't make any difference as at boot time only /boot/grub2/grub.cfg will be respected.

description: updated
Revision history for this message
Jimmy (lafonj9) wrote :

I'm also running into this problem but on an aarch64 server. Running "grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg" looks to work in the logs but the final image does not actually contain the file. Have you been able to find a workaround for this? It feels to me like changes to the efi partition are just not getting written to the final image.

Revision history for this message
Clark Boylan (cboylan) wrote :

I'll try to expand on this a bit more based on some email conversations.

DIB currently assumes that the grub config is at /boot/grub/grub.cfg or /boot/grub2/grub.cfg

When booting under UEFI the appropriate EFI executable is chosen and executed. In the case of linux installs this tends to be an EFI executable that starts up grub with the appropriate config. To do this properly this EFI executable starts grub relative to its config dir (I think, this is based on reading of blog posts and inspecting my local EFI and grub setups). On Ubuntu this EFI executable starts grub in /boot/grub and then the grub config is there to be found.

On CentOS it appears the expectation is the EFI executable and the grub config live in the same location on the EFI System Partition, /boot/efi/EFI/centos/. This means the current DIB element for bootloader setup isn't working (doesn't result in working paths for grub config when EFI is used to boot).

To work around this some, like Jimmy, have a finalize script that runs after the DIB provided finalize script to try and shim the grub config into the location CentOS expects it: https://github.com/cachengo/rec-build-tools/blob/dib_elements/dib_elements/myproduct/finalise.d/99-fix-grub-console#L23-L34.

It is my understanding that this works if they perform that manual copy at the end of this script. However the "grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg" is not sufficient. (Please point out if I've gotten this wrong).

I think what we want in DIB is better understanding of where these EFI executables expect the grub config to be then ensure we put the grub config in that location. Unfortunately, I expect this to vary by distro as each of them is providing their own shims and things for secure boot and I don't think there is a consistent approach to launching grub. It is possible that if we always write it to /boot/grub|boot/grub2|/boot/efi/EFI/$distro we'd cover enough systems that things mostly just work (my opensuse system seems to do like centos and put it in the distro ESP dir too).

Revision history for this message
Clark Boylan (cboylan) wrote :
Revision history for this message
Clark Boylan (cboylan) wrote :

As additional datapoints my x86 installations of ubuntu xenial and opensuse tumbleweed both have a grub.cfg located in the ESP. However, this cfg is merely a shim to load the main config at /boot/grub*/grub.cfg.

I wonder if we could make such a setup universal with dib installed UEFI setups? I think this may be possible through the use of `grub-mkimage -p /boot/grub` but I don't really have a good way to test that currently.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.