#1038 Issue closed: "rear mkrescue" fails with "BUG! Unknown bootloader" for 'GRUB2' and 'GRUB2-EFI'

Labels: bug, fixed / solved / done

gsbit opened issue at 2016-10-19 11:24:

  • rear version (/usr/sbin/rear -V):
    Relax-and-Recover 1.19 / Git
  • OS version (cat /etc/rear/os.conf or lsb_release -a):
    OS_VENDOR=SUSE_LINUX
    OS_VERSION=12
  • rear configuration files (cat /etc/rear/site.conf or cat /etc/rear/local.conf):
OUTPUT=ISO
BACKUP=NBU
ISO_DIR=/usertmp
TIMESYNC=NTP
GRUB_RESCUE=n
PROGS=( "${PROGS[@]}" "/usr/sbin/vconfig" "/sbin/vconfig" "/sbin/arp" )
TMPDIR=/usertmp
  • Brief description of the issue:
    Starting rear mkrescue failed with the following error:
$ rear -v mkrescue
Relax-and-Recover 1.19 / Git
Using log file: /var/log/rear/rear-servername.log
Creating disk layout
ERROR: BUG BUG BUG!  Unknown bootloader (GRUB2) - ask for sponsoring to get this fixed 
Aborting due to an error, check /var/log/rear/rear-servername.log for details
Terminated
  • Work-around, if any:
    Change the following line in the file /usr/share/rear/layout/save/default/45_check_bootloader_files.sh
OLD:
GRUB) CHECK_CONFIG_FILES=( ${CHECK_CONFIG_FILES[@]}  /etc/grub.cfg /etc/grub2.cfg /boot/grub2/grub2.cfg /boot/grub/grub.cfg )
NEW:
GRUB|GRUB2) CHECK_CONFIG_FILES=( ${CHECK_CONFIG_FILES[@]}  /etc/grub.cfg /etc/grub2.cfg /boot/grub2/grub2.cfg /boot/grub/grub.cfg )

Because the variable "myBOOTloader" in SLES 12 is "GRUB2":

$ cat /var/lib/rear/recovery/bootloader 
GRUB2

After this change it works as expected.

gozora commented at 2016-10-19 11:56:

@gsbit I'm just curious, because I have a feeling I've hit something similar and forget to report it ...
Can you please post here content of your /etc/sysconfig/bootloaer ?

@jsmeix In my case I had "EFI-GRUB or EFI-GRUB2" (or similar), which resulted to message like this.
I don't have currently access to this machine, I'll check it later today.

jsmeix commented at 2016-10-19 12:13:

This is very unexpected because I had run rear
many times on SLE12 systems.

@gsbit
I need a debug log to understand what happens on your system.
Please run "rear -d -D mkrescue" and provide the log file.

In particular I am interested what happens on your system while
/usr/share/rear/prep/default/50_guess_bootloader.sh
runs i.e. what happens on your system that results
that myBOOTloader="GRUB2".

jsmeix commented at 2016-10-19 12:20:

In https://github.com/rear/rear/pull/1039 I did
the fix as in https://github.com/rear/rear/issues/1038#issue-183934943

@gsbit
nevertheless I like your debug log to understand what goes on.

jsmeix commented at 2016-10-19 13:22:

I can reproduce it.
Some of the latest commits before 1.19 caused it.

It works for me with a bit older git clone with latest
commit 6c31e79dc6a21b891ee644f3ffacd22761b698f9
"Merge pull request #1009 from
jsmeix/correct_misspelled_forms_to_Relax-and-Recover_issue1008"

If fails on the same machine with a git clone of current master.

That machine is SLES12-SP2 with

# egrep -v '^#|^$' /etc/sysconfig/bootloader 
LOADER_TYPE="grub2"
SECURE_BOOT="no"
TRUSTED_BOOT="no"

In both cases I get

# cat var/lib/rear/recovery/bootloader 
GRUB2

which indicates the fix in https://github.com/rear/rear/pull/1039
is actually needed but somehow that did not matter before
the last few commits.

Investigating...

jsmeix commented at 2016-10-19 13:34:

Where it had worked I get in the "rear -d -D mkrescue" log

2016-10-19 15:15:30.863200265 Entering debugscripts mode via 'set -x'.
+ source /root/rear.old/usr/share/rear/prep/default/50_guess_bootloader.sh
++ [[ -f /etc/sysconfig/bootloader ]]
+++ cut -d= -f2
+++ sed -e 's/"//g'
+++ grep LOADER_TYPE /etc/sysconfig/bootloader
++ my_bootloader=grub2
++ [[ ! -z grub2 ]]
++ tr '[a-z]' '[A-Z]'
++ echo grub2
++ return
+ test 1
+ Debug 'Leaving debugscripts mode (back to previous bash flags and options settings).'
...
2016-10-19 15:15:31.719738548 Entering debugscripts mode via 'set -x'.
+ source /root/rear.old/usr/share/rear/layout/save/default/45_check_bootloader_files.sh
+++ cat /root/rear.old/var/lib/rear/recovery/bootloader
++ myBOOTloader=GRUB2
++ case $myBOOTloader in
+ test 1
+ Debug 'Leaving debugscripts mode (back to previous bash flags and options settings).'

In contrast where it does not work I get in the log:

2016-10-19 15:14:37.376125575 Entering debugscripts mode via 'set -x'.
+ source /root/rear/usr/share/rear/prep/default/50_guess_bootloader.sh
++ [[ -f /etc/sysconfig/bootloader ]]
+++ cut -d= -f2
+++ sed -e 's/"//g'
+++ grep LOADER_TYPE /etc/sysconfig/bootloader
++ my_bootloader=grub2
++ [[ ! -z grub2 ]]
++ echo grub2
++ tr '[a-z]' '[A-Z]'
++ return
+ test 1
+ Debug 'Leaving debugscripts mode (back to previous bash flags and options settings).'
...
2016-10-19 15:14:38.438816085 Entering debugscripts mode via 'set -x'.
+ source /root/rear/usr/share/rear/layout/save/default/45_check_bootloader_files.sh
+++ cat /root/rear/var/lib/rear/recovery/bootloader
++ myBOOTloader=GRUB2
++ case $myBOOTloader in
++ BugError 'Unknown bootloader (GRUB2) - ask for sponsoring to get this fixed'

Inspecting usr/share/rear/layout/save/default/45_check_bootloader_files.sh
where it works shows only

case $myBOOTloader in
    EFI)  CHECK_CONFIG_FILES=( ${CHECK_CONFIG_FILES[@]} /boot/efi/EFI/*/grub*.cfg )
        ;;
    GRUB) CHECK_CONFIG_FILES=( ${CHECK_CONFIG_FILES[@]}  /etc/grub.cfg /etc/grub2.cfg /boot/grub2/grub2.cfg /boot/grub/grub.cfg )
        ;;
    LILO) CHECK_CONFIG_FILES=( ${CHECK_CONFIG_FILES[@]} /etc/lilo.conf )
        ;;
    ELILO) CHECK_CONFIG_FILES=( ${CHECK_CONFIG_FILES[@]} /etc/elilo.conf )
        ;;
esac

i.e. there is not yet a BugError default case.

The BugError default case was added by @gdha in his
commit d15591e65461dfa43df6b7dbf23015d8e5598648
with that non-matching commit message:

    All license references are now pointing to the COPYING file (which is the gpl license v3.0).
    REAR should only reference to GPL v3.0 from now on - if otherwise seen, just report it back
    Related to issue #825

It seems that additional change (added BugError default case
in 45_check_bootloader_files.sh) slipped somehow in
by accident?

jsmeix commented at 2016-10-19 13:39:

Ha!
That added BugError default case in 45_check_bootloader_files.sh
already caused a regression on POWER based systems, see
https://github.com/rear/rear/commit/d15591e65461dfa43df6b7dbf23015d8e5598648#commitcomment-19352224
which got fixed by
https://github.com/rear/rear/commit/e8b7614829d534c44eeb918f49c8a00ef303b1d9

jsmeix commented at 2016-10-19 13:50:

With https://github.com/rear/rear/pull/1039
merged, the issue is fixed.

@gsbit
I do no longer need your debug log to understand what goes on.
Many thanks for your issue report!

jsmeix commented at 2016-10-19 13:53:

Tested with newest rear master code
(with https://github.com/rear/rear/pull/1039 merged)
on that same SLE12 system as above
and now it works again.

gsbit commented at 2016-10-19 14:22:

Thank you for the quik fix!

gdha commented at 2016-10-19 14:47:

@jsmeix sorry - I shouldn't have changed the 45_check_bootloader_files.sh while doing the LICENSE/COPYING batch change, but I couldn't help it as it was stronger then me. A catch all was too generic IMHO so a BugError was required to be sure we support the bootloader found.

gozora commented at 2016-10-19 18:34:

Hello @jsmeix
As I've mentioned earlier today, my SLES12 SP1 with UEFI boot, ends up with similar error:

ERROR: BUG BUG BUG!  Unknown bootloader (GRUB2-EFI) - ask for sponsoring to get this fixed

This comes from:

suse12:~ # grep LOADER_TYPE /etc/sysconfig/bootloader
LOADER_TYPE="grub2-efi"

Once I remove /etc/sysconfig/bootloader, /var/lib/rear/recovery/bootloader contains EFI as a bootloader, which is recognized by ReaR so all works fine.

gdha commented at 2016-10-20 06:59:

I will re-open this issue for now to capture new cases

jsmeix commented at 2016-10-20 08:07:

@gozora
could you do a pull request that adds support for 'GRUB2-EFI'.
I guess it is as easy as https://github.com/rear/rear/pull/1039
but you can just test it so that I would prefer when you do it.
Many thanks in advance!

gdha commented at 2016-10-20 08:09:

@gozora you were saying that /var/lib/rear/recovery/bootloader contains EFI as bootloader, right?
I think we better keep the LOADER_TYPE="grub2-efi" as bootloader identification, and adapt script 45_check_bootloader_files.sh to recognize it as a valid bootloader.

jsmeix commented at 2016-10-20 08:12:

@gdha
no worries!

SUSE's official RPM package for SLE12-SP2 customers
is "rear118a" which does not contain those latest commits.
Regarding "rear118a" for SLE12-SP2 see
"rear / rear116 / rear1172a / rear118a" at
https://en.opensuse.org/SDB:Disaster_Recovery

And SLE12 users that are no SUSE customers
can get voluntary help here.

gozora commented at 2016-10-20 08:35:

@gdha

you were saying that /var/lib/rear/recovery/bootloader contains EFI as bootloader, right?
I think we better keep the LOADER_TYPE="grub2-efi" as bootloader identification, and adapt script 45_check_bootloader_files.sh to recognize it as a valid bootloader.

/var/lib/rear/recovery/bootloader contains EFI only if I remove /etc/sysconfig/bootloader prior starting rear mkrescue. This is however very dirty workaround!
If I used default SLES11 SP1 configuration /var/lib/rear/recovery/bootloader contains GRUB2-EFI, which is not recognized by ReaR.
I guess there is some code that first checks for existence of sysconfig/bootloader and if not found, it tries to guess bootloader by him self.

gozora commented at 2016-10-20 08:37:

@jsmeix

could you do a pull request that adds support for 'GRUB2-EFI'.

Certainly, I'll check the code later today.

gozora commented at 2016-10-20 09:11:

hmm, According comments in my /etc/sysconfig/bootloader, LOADER_TYPE can be one of following:

  • grub
  • grub2
  • grub2-efi
  • none

Guess which option did I try as next :-). Correct, none.

And I have even more interesting result in /var/lib/rear/recovery/bootloader.

sles12:~ # cat /var/lib/rear/recovery/bootloader
GRUB2-EFI
NONE

which resulted again to:

sles12:~ # rear mkbackuponly
ERROR: BUG BUG BUG!  Unknown bootloader (GRUB2-EFI
NONE) - ask for sponsoring to get this fixed 
=== Issue report ===
Please report this unexpected issue at: https://github.com/rear/rear/issues
Also include the relevant bits from /var/log/rear/rear-sles12.log

HINT: If you can reproduce the issue, try using the -d or -D option !
====================
Aborting due to an error, check /var/log/rear/rear-sles12.log for details
Terminated

gozora commented at 2016-10-20 09:14:

And one more. having content of /etc/sysconfig/bootloader like:

sles12:~ # grep LOADER_TYPE /etc/sysconfig/bootloader
#LOADER_TYPE="Vladimir"
#LOADER_TYPE="gozora"
#LOADER_TYPE="none"
LOADER_TYPE="none"

I get:

sles12:~ # cat /var/lib/rear/recovery/bootloader
VLADIMIR
GOZORA
NONE
NONE

gdha commented at 2016-10-20 09:31:

@gozora Just fixed the issue with multiple LOADER_TYPE settings in /etc/sysconfig/bootloader

jsmeix commented at 2016-10-20 09:47:

@gdha
because of @gozora findings I wonder if the current
BugError default case in 45_check_bootloader_files.sh
is really useful.

Perhaps the default case in 45_check_bootloader_files.sh
should better be used as fallback to use GRUB2 and
output a message to the user that GRUB2 is used
as fallback bootloader?

The underlying basic question is if rear could use
reasonable fallbacks when things are not clear
or
if rear should better always error out when things are
not clear to always work strictly on the safe side?

Cf. "Try to care about possible errors" in
https://github.com/rear/rear/wiki/Coding-Style

jsmeix commented at 2016-10-20 12:22:

I like to even more fix the fix for the issue with multiple
LOADER_TYPE settings in /etc/sysconfig/bootloader:
https://github.com/rear/rear/pull/1042

jsmeix commented at 2016-10-20 13:36:

Only FYI:
I did some further cosmetic improvements
for 45_check_bootloader_files.sh via
https://github.com/rear/rear/commit/f1bc3b5730d99545fa4d60bcf277bee484262ac6
and
https://github.com/rear/rear/commit/15bb61e4fc68c4edf2efd5d30187a24f36574071

jsmeix commented at 2016-11-24 17:55:

The issue is marked as "fixed"
so that I asssume it can be closed.


[Export of Github issue for rear/rear.]