Bug 1737042

Summary: uefi: Search for Grub2 modules in /usr/lib/grub*/x86_64-efi and not in /boot
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: rearAssignee: Pavel Cahyna <pcahyna>
Status: CLOSED ERRATA QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: djez, fkrska, jan.public, ovasik, pcahyna
Target Milestone: rc   
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: rear-2.4-12.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 15:47:07 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:    
Bug Blocks: 1746915, 1755139    

Description Renaud Métrich 2019-08-02 12:27:27 UTC
Description of problem:

On Fedora and RHEL systems, Grub2 UEFI modules live in /usr/lib/grub*/x86_64-efi, not /boot, unless grub2-install is executed, but executing this tool is not needed with UEFI at all.
Additionally, only UEFI modules should be looked for, so /boot cannot be
searched but only /boot/grub2/x86_64-efi (similarly /usr/lib/grub*/x86_64-efi), otherwise we could get some false positives on dual boot systems (UEFI + Legacy), since modules for Legacy will also match, which is wrong.

This is a backport request for PR #2199 (https://github.com/rear/rear/pull/2199)

This causes the following error when booting the ReaR ISO:

Unknown command 'configfile'.
error: ../../grub-core/kern/fs.c:120:unknown filesystem
Entering rescue mode...
grub rescue> _


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

rear-2.4 (RHEL7 and RHEL8)


How reproducible:

Always with UEFI systems

Steps to Reproduce:
1. Install a UEFI system
2. Install and execute ReaR

  # yum -y install rear
  # rear -dD mkrescue

3. Check the ReaR log and search for "grub2-mkimage -v -O x86_64-efi"

  # grep "grub2-mkimage -v -O x86_64-efi" /var/log/rear/rear-*.log

Actual results:

++ grub2-mkimage -v -O x86_64-efi -c /tmp/rear.BUo5lpm4WBrgx8w/tmp/mnt/EFI/BOOT/embedded_grub.cfg -o /tmp/rear.BUo5lpm4WBrgx8w/tmp/mnt/EFI/BOOT/BOOTX64.efi -p /EFI/BOOT

--> no module listed

Expected results:

++ grub2-mkimage -v -O x86_64-efi -c /tmp/rear.RhzDyyF3zXrQsWs/tmp/mnt/EFI/BOOT/embedded_grub.cfg -o /tmp/rear.RhzDyyF3zXrQsWs/tmp/mnt/EFI/BOOT/BOOTX64.efi -p /EFI/BOOT part_gpt part_msdos fat ext2 normal chain boot configfile linux jfs iso9660 usb usbms usb_keyboard video udf ntfs all_video gzio efi_gop reboot search test echo btrfs

--> modules being built into the image

Additional info:

The root cause is that only /boot is searched for Grub2 modules (ReaR tries to embed modules which do not exist on RHEL, see PR#2001). /usr/lib/grub*/x86_64-efi should be searched instead, and *only* this path (not /usr/lib/grub* globally).

Comment 1 Pavel Cahyna 2019-08-02 12:33:18 UTC
Is it a new bug in ReaR 2.4? ISTR testing a restore on UEFI successfully with some previous ReaR version.

Comment 2 Pavel Cahyna 2019-08-02 12:36:45 UTC
Also, should I clone it to RHEL 7?

Comment 3 Renaud Métrich 2019-08-02 12:37:51 UTC
I'll clone it to RHEL7, it's a hidden bug from Upstream.
I'm currently writing a KCS.

Comment 4 Pavel Cahyna 2019-08-05 08:37:49 UTC
(In reply to Pavel Cahyna from comment #1)
> Is it a new bug in ReaR 2.4? ISTR testing a restore on UEFI successfully
> with some previous ReaR version.

I was probably mistaken - I think I tested only a non-UEFI case because UEFI was harder to automate.

Comment 5 Pavel Cahyna 2019-08-19 17:19:43 UTC
Am I right that it is a regression introduced in bz1663515 (PR #2001) ?

Comment 6 Renaud Métrich 2019-08-21 07:34:59 UTC
Yes it's a regression from PR #2001.

Comment 7 Pavel Cahyna 2019-08-30 11:37:58 UTC
There is a fix upstream, although I would like to improve it.

Comment 9 Pavel Cahyna 2019-12-09 16:37:14 UTC
Hi Renaud, I made what I believe is an improvement upstream, because I find the current code very fragile, as it uses many assumptions on what modules to use and where to find them. It is https://github.com/rear/rear/pull/2293. Can you please review it? I would like to include it in the backport. It also fixes a related issue that GRUB_RESCUE is not working on UEFI (xfs is not among the default modules, so /boot can not be found).

Comment 10 Renaud Métrich 2019-12-10 08:21:53 UTC
Good job.

Comment 12 Pavel Cahyna 2020-03-06 10:58:40 UTC
I propose to change the summary to something like "Error when booting the ReaR ISO on UEFI: Unknown command 'configfile'", because the current summary is misleading after my fix.

Comment 15 errata-xmlrpc 2020-04-28 15:47:07 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, 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-2020:1648