Bug 2048904

Summary: Cannot EFI chainload onto local disk when EFI partition is in Software Raid
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
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: 8.5CC: jaredz, jstodola, mlewando, pjanda, pzatko, release-test-team-automation, rharwood, sbarcomb
Target Milestone: rcKeywords: OtherQA
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: grub2-2.02-117.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2049220 (view as bug list) Environment:
Last Closed: 2022-05-10 15:31:42 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: 2060948, 2061252    
Bug Blocks: 2049220    
Attachments:
Description Flags
Proposed patch to Upstream
none
Patch improving error message (not in Upstream project)
none
Proposed patch to Upstream none

Description Renaud Métrich 2022-02-01 06:45:16 UTC
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.

Comment 1 Renaud Métrich 2022-02-01 10:39:36 UTC
Created attachment 1858328 [details]
Proposed patch to Upstream

Comment 2 Renaud Métrich 2022-02-01 10:46:43 UTC
Upstream thread: https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00001.html

Comment 6 Renaud Métrich 2022-02-15 13:15:42 UTC
Created attachment 1861221 [details]
Patch improving error message (not in Upstream project)

Comment 7 Renaud Métrich 2022-02-15 13:16:37 UTC
Created attachment 1861222 [details]
Proposed patch to Upstream

Comment 9 Renaud Métrich 2022-02-15 13:20:34 UTC
Upstream thread: https://lists.gnu.org/archive/html/grub-devel/2022-02/msg00075.html

Comment 12 Renaud Métrich 2022-02-28 08:00:50 UTC
Verified on grub2-2.02-117.el8:

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 13 Jan Stodola 2022-02-28 11:40:27 UTC
Thank you for verification, Renaud.
Marking as Verified:Tested.

Comment 22 errata-xmlrpc 2022-05-10 15:31:42 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 (Low: grub2 security, bug fix, and enhancement update), 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/RHSA-2022:2110