Bug 1479002

Summary: REAR "ERROR: Cannot find required programs: efibootmgr", after updating to 7.4.
Product: Red Hat Enterprise Linux 7 Reporter: Ryan Blakley <rblakley>
Component: rearAssignee: Pavel Cahyna <pcahyna>
Status: CLOSED ERRATA QA Contact: Tereza Cerna <tcerna>
Severity: high Docs Contact: Petr Bokoc <pbokoc>
Priority: urgent    
Version: 7.4CC: baitken, fkrska, hartsjc, jbastian, jentrena, kwalker, ovasik, pbokoc, pcahyna, qe-baseos-daemons, rblakley, salmy, tcerna
Target Milestone: rcKeywords: Patch, Regression, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rear-2.00-3.el7 Doc Type: Bug Fix
Doc Text:
*ReaR* no longer requires "dosfsck" and "efibootmgr" on non-UEFI systems Previously, *ReaR* (Relax-and-Recover) incorrectly required the "dosfsck" and "efibootmgr" utilities installed on systems that do not use UEFI. As a consequence, if the utilities were missing, the "rear mkrescue" command failed with an error. This bug has been fixed, and *ReaR* now requires the mentioned utilities to be installed only on UEFI systems.
Story Points: ---
Clone Of:
: 1492561 (view as bug list) Environment:
Last Closed: 2018-04-10 18:43:20 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:
Bug Depends On:    
Bug Blocks: 1420851, 1492561    

Description Ryan Blakley 2017-08-07 16:56:16 UTC
Description of problem: REAR "ERROR: Cannot find required programs: efibootmgr", after updating to 7.4. With 7.4 grub2-common is a new dependency that gets pulled in, which creates the /boot/efi/EFI/redhat directory on non-uefi installed machines.


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


Steps to Reproduce:
** First way
1. Install 7.4 and run # rear -v mkbackup

** Second way if on 7.3 or below.
1. Yum update grub2* and rear, then run # rear -v mkbackup


Actual results:
# rear -d -v mkbackup
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-ryan-rhel7.log
ERROR: Cannot find required programs: efibootmgr
Aborting due to an error, check /var/log/rear/rear-ryan-rhel7.log for details
You should also rm -Rf /tmp/rear.3EZIbCfZn9geS4c
Terminated


Expected results:
Continue with the backup and not terminate.


Additional info: 
It looks like a similar issue has been reported upstream at https://github.com/rear/rear/issues/1239. But the fix for that issue doesn't work on 7.4, because it's only checking if the directory exist. It should be checking if /boot/efi is actually mounted. I did some testing, and the below change works correctly on non-uefi, and uefi based installs without any errors.

diff -up /usr/share/rear/prep/default/310_include_uefi_tools.sh.bak /usr/share/rear/prep/default/310_include_uefi_tools.sh
--- /usr/share/rear/prep/default/310_include_uefi_tools.sh.bak	2017-08-07 11:29:12.863665290 -0400
+++ /usr/share/rear/prep/default/310_include_uefi_tools.sh	2017-08-07 11:33:15.924439002 -0400
@@ -6,7 +6,7 @@ if grep -qw 'noefi' /proc/cmdline; then
 fi
 
 # next step, is checking /boot/efi directory (we need it)
-if [[ ! -d /boot/efi ]]; then
+if ! grep -q '/boot/efi' /proc/mounts; then
     return    # must be mounted
 fi

Comment 2 Blair Aitken 2017-08-15 13:50:27 UTC
Hello everyone,

I have 2 different customers that have confirmed that the suggested workaround by Ryan (under Additional info section) works in their environment.

Comment 3 Ryan Blakley 2017-08-15 23:33:46 UTC
The customer on 01903555 also confirmed the workaround I proposed fixed their issue, is there anyway we can get a fix pushed quicker. This bug breaks rear backups completely on non-uefi systems?

Comment 10 Pavel Cahyna 2017-09-11 09:54:56 UTC
Quick workaround without patching package files: install the dosfstools and efibootmgr packages.
yum install dosfstools efibootmgr

Comment 30 Jeff Bastian 2017-09-15 19:23:52 UTC
*** Bug 1492190 has been marked as a duplicate of this bug. ***

Comment 31 Jeff Bastian 2017-09-15 19:24:08 UTC
(In reply to Ryan Blakley from comment #0)
>  # next step, is checking /boot/efi directory (we need it)
> -if [[ ! -d /boot/efi ]]; then
> +if ! grep -q '/boot/efi' /proc/mounts; then
>      return    # must be mounted
>  fi


I would suggest checking for the /sys/firmware/efi directory instead.  This is created by the kernel only on systems with actual UEFI firmware.

Even a non-UEFI system could mount a filesystem at /boot/efi so this is not a very reliable test.  (I don't know _why_ someone would mount something here on a non-UEFI system, but I've seen weirder things. :-))

Comment 32 Ryan Blakley 2017-09-15 19:47:02 UTC
(In reply to Jeff Bastian from comment #31)
> (In reply to Ryan Blakley from comment #0)
> >  # next step, is checking /boot/efi directory (we need it)
> > -if [[ ! -d /boot/efi ]]; then
> > +if ! grep -q '/boot/efi' /proc/mounts; then
> >      return    # must be mounted
> >  fi
> 
> 
> I would suggest checking for the /sys/firmware/efi directory instead.  This
> is created by the kernel only on systems with actual UEFI firmware.
> 
> Even a non-UEFI system could mount a filesystem at /boot/efi so this is not
> a very reliable test.  (I don't know _why_ someone would mount something
> here on a non-UEFI system, but I've seen weirder things. :-))

The latest fix no longer depends on the mount. My point for checking if it was mounted was due to the fact that rear depends on the efi files to be under /boot/efi. So if we only check if the directory exist, then the efi files may not be there if /boot/efi wasn't mounted. But again the upstream fixes rearrange the prep files to properly, and more cleanly fix this issue.

Comment 35 Tereza Cerna 2018-01-08 10:03:06 UTC
===================
Verified in:
   rear-2.00-4.el7
   non-UEFI machine
PASS
===================

# cat /etc/rear/local.conf
OUTPUT=ISO
BACKUP=NETFS
BACKUP_URL=nfs://localhost/mnt/rear/

# rear -v mkbackup
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-ibm-p8-kvm-06-guest-07.log
Using backup archive 'backup.tar.gz'
mkdir: created directory '/var/lib/rear/output'
Creating disk layout
Creating root filesystem layout
Copying logfile /var/log/rear/rear-ibm-p8-kvm-06-guest-07.log into initramfs as '/tmp/rear-ibm-p8-kvm-06-guest-07-partial-2018-01-08T03:22:36-0500.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-ibm-p8-kvm-06-guest-07.iso (80M)
Copying resulting files to nfs location
Saving /var/log/rear/rear-ibm-p8-kvm-06-guest-07.log as rear-ibm-p8-kvm-06-guest-07.log to nfs location
Creating tar archive '/tmp/rear.GhQPqVERRYvBgLZ/outputfs/ibm-p8-kvm-06-guest-07/backup.tar.gz'
Preparing archive operationOK
Archived 1822 MiB in 248 seconds [avg 7524 KiB/sec]

See output: 
http://lab-02.rhts.eng.bos.redhat.com/beaker/logs/tasks/66224+/66224272/TESTOUT.log

===================
Reproduced in:
   rear-2.00-2.el7
   non-UEFI machine
FAIL
===================

# cat /etc/rear/local.conf
OUTPUT=ISO
BACKUP=NETFS
BACKUP_URL=nfs://localhost/mnt/rear/

# rear -v mkbackup
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-sheep-41.log
Using backup archive 'backup.tar.gz'
ERROR: Cannot find required programs: dosfsck efibootmgr
Aborting due to an error, check /var/log/rear/rear-sheep-41.log for details

Comment 38 errata-xmlrpc 2018-04-10 18:43:20 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-2018:1000