Bug 1492190

Summary: rear looks for efibootmgr on non-UEFI systems
Product: Red Hat Enterprise Linux 7 Reporter: Jeff Bastian <jbastian>
Component: rearAssignee: Jakub Mazanek <jmazanek>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4-AltCC: jbastian, pcahyna, tcerna
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-15 19:23:52 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:

Description Jeff Bastian 2017-09-15 17:36:11 UTC
Description of problem:
rear fails while looking for efibootmgr and /boot/efi on ppc64/ppc64le which are not UEFI platforms.

~]# uname -i
ppc64le

~]# rear -dv mkbackup
...
ERROR: Cannot find required programs: efibootmgr

~]# rear -dv mkbackup
...
ERROR: Could not find a matching kernel in /boot/efi/efi/redhat !


This is because it assumes the system is a UEFI platform if the /boot/efi directory merely exists, however, the new grub2-common package in RHEL 7.4 creates this empty directory on all systems, regardless of firmware type.  A better check would be to look for the /sys/firmware/efi directory.

~]# rpm -q grub2-common
grub2-common-2.02-0.64.el7.noarch

~]# rpm -ql grub2-common | grep efi
/boot/efi/EFI/redhat

~]# less /usr/share/rear/prep/default/310_include_uefi_tools.sh
# When /boot/efi is mounted we copy the UEFI binaries we might need

# If noefi is set, we can ignore UEFI altogether
if grep -qw 'noefi' /proc/cmdline; then
    return
fi

# next step, is checking /boot/efi directory (we need it)
if [[ ! -d /boot/efi ]]; then                                        # <--- BUG
    return    # must be mounted
fi

REQUIRED_PROGS=( "${REQUIRED_PROGS[@]}"
dosfsck
efibootmgr
)
...
...


Version-Release number of selected component (if applicable):
rear-2.00-2.el7.ppc64le
grub2-common-2.02-0.64.el7.noarch

How reproducible:
always

Steps to Reproduce:
1. run rear on non-UEFI platforms with an empty /boot/efi directory

Actual results:
rear fails trying to do UEFI-ish things

Expected results:
rear does not do UEFI-ish things on non-UEFI platforms

Additional info:

Comment 1 Jeff Bastian 2017-09-15 17:38:02 UTC
grub2-install had a similar problem, see bug 1443809

Comment 2 Jeff Bastian 2017-09-15 17:43:58 UTC
310_include_uefi_tools.sh is not the only file with this check:

~]# rpm -ql rear | xargs grep -l -- '-d /boot/efi' 2>/dev/null
/usr/share/rear/output/ISO/Linux-ia64/400_create_local_efi_dir.sh
/usr/share/rear/output/OBDR/Linux-ia64/400_create_local_efi_dir.sh
/usr/share/rear/prep/default/310_include_uefi_tools.sh
/usr/share/rear/prep/default/320_include_uefi_env.sh


There may be more files that need updates to look for /sys/firmware/efi instead of /boot/efi.

Comment 3 Pavel Cahyna 2017-09-15 18:56:57 UTC
This is almost certainly a duplicate of bz1479002, please try the test build provided there.

Comment 4 Pavel Cahyna 2017-09-15 19:06:06 UTC
(In reply to Jeff Bastian from comment #0)
> ~]# rear -dv mkbackup
> ...
> ERROR: Could not find a matching kernel in /boot/efi/efi/redhat !

It tries to find it there only if not found under /boot. If we remove the EFI part, it will just fail with an error message that it can not find a matching kernel under /boot. Where does one find the kernel on RS/6000 (or what machine is that)?

Comment 5 Jeff Bastian 2017-09-15 19:23:52 UTC
I was testing on a PowerNV (non-virt or bare metal) ppc64le system.  The kernel is in the usual spot in /boot.

~]# ls /boot/vmlinuz*
/boot/vmlinuz-0-rescue-719f435d87674d27a5e92dd3cdf9da93
/boot/vmlinuz-4.11.0.ppc64le

Agreed, this is a dup of 1479002.  Sorry for the noise!

*** This bug has been marked as a duplicate of bug 1479002 ***

Comment 6 Jeff Bastian 2017-09-15 19:29:16 UTC
BTW, the test build for bug 1479002 works on my test system, thanks!

[root@localhost ~]# rpm -q rear
rear-2.00-2.el7_4.bz1479002.ppc64le

[root@localhost ~]# rear -dv mkbackup
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-localhost.log
Creating disk layout
Creating root filesystem layout
Copying logfile /var/log/rear/rear-localhost.log into initramfs as '/tmp/rear-localhost-partial-2017-09-15T19:26:40-0400.log'
Copying files and directories
Copying binaries and libraries
Copying kernel modules
Creating initramfs
Making ISO image
Wrote ISO Image /var/lib/rear/output/rear-localhost.iso (163M)
You should also rm -Rf /tmp/rear.KOdGysGFQTwhSrQ