Bug 2049220

Summary: Cannot EFI chainload onto local disk when EFI partition is in Software Raid
Product: Red Hat Enterprise Linux 9 Reporter: Robbie Harwood <rharwood>
Component: grub2Assignee: Bootloader engineering team <bootloader-eng-team>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: bootloader-eng-team, jaredz, jstodola, mlewando, pjanda, release-test-team-automation, rmetrich
Target Milestone: rcKeywords: OtherQA
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: grub2-2.06-24.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2048904 Environment:
Last Closed: 2022-05-17 15:51:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2048904    
Bug Blocks:    

Description Robbie Harwood 2022-02-01 18:23:36 UTC
+++ This bug was initially created as a clone of Bug #2048904 +++

Description of problem:

We have a customer deploying systems using Upstream Satellite product.
All his systems are on UEFI and boot through the network, loading Grub2 and a configuration file used to chainload to the local disk of the system, similar to this excerpt below:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
menuentry 'Chainload Grub2 EFI from ESP' --id local {
  unset root
  # search for local disk EFI partition
  search --file --no-floppy --set=root /EFI/BOOT/BOOTX64.EFI
  echo found $root
  # select the right local disk bootloader
  if [ -f ($root)/EFI/BOOT/grubx64.efi ]; then
    chainloader ($root)/EFI/BOOT/grubx64.efi
  elif [ -f ($root)/EFI/fedora/grubx64.efi ]; then
    chainloader ($root)/EFI/fedora/grubx64.efi
  ...
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

When the system has its EFI partition in Software Raid, the "search --file" command returns "md/boot_efi" device as new root device, which prevents "chainloader" command from working because the device is not a EFI disk but a virtual device, which is not supported by the "chainloader" command.

The solution consists in adding a new "--efidisk-only" option to "search" to limit searching for EFI disks only:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
search --file --no-floppy --efidisk-only --set=root /EFI/BOOT/BOOTX64.EFI
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------


Version-Release number of selected component (if applicable):

all grub releases


How reproducible:

Always

Steps to Reproduce:
1. Setup a VM with EFI and softraid
2. Boot the VM from the network using chainloading grub.cfg above

Actual results:

"not a valid root device" error

Expected results:

can chainload

Additional info:

A partial workaround consists in adding a "--hint-efi" on the various disks making the softraid, e.g. "--hint-efi=hd0, --hint-efi=hd1," but this doesn't always work because there is no way to avoid "search" from returning the softraid.

--- Additional comment from Renaud Métrich on 2022-02-01 05:39:36 EST ---



--- Additional comment from Renaud Métrich on 2022-02-01 05:46:43 EST ---

Upstream thread: https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00001.html

Comment 8 Renaud Métrich 2022-02-28 07:59:54 UTC
Verified on grub2-2.06-24.el9:


grub.cfg:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
ls

search --file --set=root1 /EFI/BOOT/BOOTX64.EFI
echo "Normal search: $root1"

search --file --efidisk-only --set=root2 /EFI/BOOT/BOOTX64.EFI
echo "efidisk-only search: $root2"
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Grub output:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
(proc) (hd0) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) (hd2) (hd2,msdos2) (lvm/rhel-root) (lvm/rhel-swap) (md/pv00) (md/boot_efi) (md/boot) 

Normal search: md/boot_efi
efidisk-only search: hd0,gpt2
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Comment 9 Jan Stodola 2022-02-28 12:36:26 UTC
Thank you for verification, Renaud.
Marking as Verified:Tested.

Comment 16 errata-xmlrpc 2022-05-17 15:51:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: grub2), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3925