#2199 PR merged: uefi: Search for Grub2 modules in /usr/lib/grub*/x86_64-efi and not in /boot

Labels: enhancement, cleanup, fixed / solved / done

rmetrich opened issue at 2019-08-02 12:15:

Relax-and-Recover (ReaR) Pull Request Template

Please fill in the following items before submitting a new pull request:

Pull Request Details:
  • Type: Bug Fix

  • Impact: Normal

  • Reference to related issue (URL): #2001

  • How was this pull request tested?

Tested on RHEL7 UEFI, RHEL8 UEFI + SLES12SP3 UEFI

  • Brief description of the changes in this pull request:

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.

On SuSE systems, Grub2 UEFI modules also live in /usr/lib/grub*/x86_64-efi, but there is also a copy in /boot, so it's not needed searching in /boot 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.

rmetrich commented at 2019-08-02 12:25:

This issue 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> _

pcahyna commented at 2019-08-05 09:36:

It does not seem right that ReaR needs to know such Grub-related details. Isn't there a Grub command that would figure them out itself? Like grub2-mkstandalone or grub2-mkrescue?

rmetrich commented at 2019-08-05 11:36:

It does not seem right that ReaR needs to know such Grub-related details. Isn't there a Grub command that would figure them out itself? Like grub2-mkstandalone or grub2-mkrescue?

  • grub2-mkrescue creates a USB/CDROM/floppy image, not usable here
  • grub2-mkstandalone doesn't work for some reason, even when embedding the grub.cfg file (goes to grub2 prompt)

pcahyna commented at 2019-08-05 11:44:

It does not seem right that ReaR needs to know such Grub-related details. Isn't there a Grub command that would figure them out itself? Like grub2-mkstandalone or grub2-mkrescue?

* `grub2-mkrescue` creates a USB/CDROM/floppy image, not usable here

Yes, ReaR would have to be changed so that the complete image would be created by grub2-mkrescue, not only the Grub image. Which would be a bigger change.

* `grub2-mkstandalone` doesn't work for some reason, even when embedding the grub.cfg file (goes to grub2 prompt)

Could it be the problem described in https://lists.gnu.org/archive/html/help-grub/2016-08/msg00011.html ? See the reply. (One should use graft point syntax, like /boot/grub/grub.cfg=./grub.cfg)

jsmeix commented at 2019-08-07 11:35:

Only as a side note regarding grub2-mkrescue see
https://github.com/rear/rear/issues/764

FYI:
I am not in the office for some weeks so that I cannot actually do
real work for ReaR, in particular I cannot test anything.

pcahyna commented at 2019-11-28 19:17:

@rmetrich this seems to work:

grub2-mkstandalone $v -O x86_64-efi -o $TMP_DIR/mnt/EFI/BOOT/BOOTX64.efi /boot/grub/grub.cfg=$TMP_DIR/mnt/EFI/BOOT/grub.cfg

(this replaces

$gmkimage $v -O x86_64-efi -c $TMP_DIR/mnt/EFI/BOOT/embedded_grub.cfg -o $TMP_DIR/mnt/EFI/BOOT/BOOTX64.efi -p "/EFI/BOOT" $grub_modules

in usr/share/rear/lib/uefi-functions.sh (https://github.com/rear/rear/pull/2199/files#diff-8766e312330f66f92f92e1da473dd4f0))

gozora commented at 2019-11-28 20:53:

Hello @pcahyna

Excerpt from man grub2-mkstandalone

...
DESCRIPTION
       Generate a standalone image (containing all modules) in the selected format
...

This is kind of similar situation as with kernel MODULES. I personally think that we should allow user to decide which modules he wants or doesn't want to use, instead of packing ReaR rescue system boot loader with all available modules.

V.

pcahyna commented at 2019-11-29 11:01:

Hello @gozora,

the problem is what to use as the default list of modules. To me it seems better to include all and let grub-mkstandalone determine where to find them rather than to try to determine a list which will always risk becoming obsolete (cf. #2001 which was the original problem being solved - the fix was leading to the problem solved here). I.e. I think ReaR tries to know too much about the internal details of Grub. If users want to override the module list, grub2-mkstandalone has a --install-modules option:

Install  only MODULES and their dependencies.  The default is to
install all available modules.

jsmeix commented at 2019-11-29 12:51:

@pcahyna
if I understand correctly what @gozora means is that
the GRUB modules behaviour in ReaR should be basically
same as the kernel modules behaviour in current ReaR which is
by default all kernel modules via MODULES=( 'all_modules' ) cf.
https://github.com/rear/rear/blob/master/usr/share/rear/conf/default.conf#L1157
but also the user has the final power and full freedom
to specify what he wants if needed.

pcahyna commented at 2019-12-03 18:22:

@jsmeix is there a supported (by ReaR) version of SLES which uses Grub2 but does not have the grub2-mkstandalone (or grub-mkstandalone) tool? Among versions listed in https://github.com/rear/rear.github.com/blob/master/documentation/release-notes-2-5.md#supported-and-unsupported-operating-systems I verified that Ubuntu 12.04 does not have it, Ubuntu 16.04, Debian 6 and RHEL 7.2 do.

jsmeix commented at 2019-12-04 10:57:

@pcahyna

on my SLES11-SP4 system:

# rpm -qa | grep -i grub
grub-0.97-172.3.2

# rpm -ql grub | grep bin/
/usr/bin/mbchk
/usr/sbin/grub
/usr/sbin/grub-crypt
/usr/sbin/grub-install
/usr/sbin/grub-install.unsupported
/usr/sbin/grub-md5-crypt
/usr/sbin/grubonce

On my SLES12-SP4 system
I have those 'grub*' RPMs

grub2-systemd-sleep-plugin-2.02-9.2.noarch
grub2-2.02-9.2.x86_64
grub2-branding-SLE-12-11.1.noarch
grub2-i386-pc-2.02-9.2.x86_64
grub2-snapper-plugin-2.02-9.2.noarch

On my SLES15 system
I have those 'grub*' RPMs

grub2-2.02-17.4.x86_64
grub2-x86_64-efi-2.02-17.4.x86_64
grub2-i386-pc-2.02-17.4.x86_64
grub2-branding-SLE-15-7.43.noarch
grub2-snapper-plugin-2.02-17.4.noarch
grub2-systemd-sleep-plugin-2.02-17.4.noarch

On my openSUSE Leap 15.0 system
I have those 'grub*' RPMs

grub2-i386-pc-2.02-lp150.13.26.1.x86_64
grub2-snapper-plugin-2.02-lp150.13.26.1.noarch
grub2-2.02-lp150.13.26.1.x86_64
grub2-systemd-sleep-plugin-2.02-lp150.13.26.1.noarch
grub2-x86_64-efi-2.02-lp150.13.26.1.x86_64
grub2-branding-openSUSE-15.0-lp150.6.1.noarch

On my SLES12-SP4 and SLES15 and openSUSE Leap 15.0 system
the 'grub2*' RPMS provide those same set of 'bin' files

/usr/bin/grub2-editenv
/usr/bin/grub2-emu
/usr/bin/grub2-emu-lite
/usr/bin/grub2-file
/usr/bin/grub2-fstest
/usr/bin/grub2-glue-efi
/usr/bin/grub2-kbdcomp
/usr/bin/grub2-menulst2cfg
/usr/bin/grub2-mkfont
/usr/bin/grub2-mkimage
/usr/bin/grub2-mklayout
/usr/bin/grub2-mknetdir
/usr/bin/grub2-mkpasswd-pbkdf2
/usr/bin/grub2-mkrelpath
/usr/bin/grub2-mkrescue
/usr/bin/grub2-mkstandalone
/usr/bin/grub2-mount
/usr/bin/grub2-render-label
/usr/bin/grub2-script-check
/usr/bin/grub2-syslinux2cfg
/usr/sbin/grub2-bios-setup
/usr/sbin/grub2-check-default
/usr/sbin/grub2-install
/usr/sbin/grub2-macbless
/usr/sbin/grub2-mkconfig
/usr/sbin/grub2-ofpathname
/usr/sbin/grub2-once
/usr/sbin/grub2-probe
/usr/sbin/grub2-reboot
/usr/sbin/grub2-set-default
/usr/sbin/grub2-sparc64-setup

On my SLES12-SP4 and SLES15 and openSUSE Leap 15.0 system
grub2-mkstandalone --help shows the same

Usage: grub2-mkstandalone [OPTION...] [OPTION] SOURCE...
Generate a standalone image (containing all modules) in the selected format

      --compress=no|xz|gz|lzo   compress GRUB files [optional]
  -d, --directory=DIR        use images and modules under DIR
                             [default=/usr/lib/grub2/<platform>]
      --fonts=FONTS          install FONTS [default=unicode]
      --install-modules=MODULES   install only MODULES and their dependencies
                             [default=all]
  -k, --pubkey=FILE          embed FILE as public key for signature checking
      --locale-directory=DIR use translations under DIR
                             [default=/usr/share/locale]
      --locales=LOCALES      install only LOCALES [default=all]
      --modules=MODULES      pre-load specified modules MODULES
      --themes=THEMES        install THEMES [default=starfield]
  -v, --verbose              print verbose messages.
      --core-compress=xz|none|auto
                             choose the compression to use for core image
  -o, --output=FILE          save output in FILE [required]
  -O, --format=FILE          generate an image in FORMAT
                             available formats: i386-coreboot, i386-multiboot,
                             i386-pc, i386-pc-pxe, i386-pc-eltorito,
                             i386-pc-tpm, i386-efi, i386-ieee1275, i386-qemu,
                             x86_64-efi, i386-xen, x86_64-xen,
                             mipsel-yeeloong-flash, mipsel-fuloong2f-flash,
                             mipsel-loongson-elf, powerpc-ieee1275,
                             sparc64-ieee1275-raw, sparc64-ieee1275-cdcore,
                             sparc64-ieee1275-aout, ia64-efi, mips-arc,
                             mipsel-arc, mipsel-qemu_mips-elf,
                             mips-qemu_mips-flash, mipsel-qemu_mips-flash,
                             mips-qemu_mips-elf, arm-uboot, arm-efi, arm64-efi
  -?, --help                 give this help list
      --usage                give a short usage message
  -V, --version              print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Graft point syntax (E.g. /boot/grub/grub.cfg=./grub.cfg) is accepted

Report bugs to <bug-grub@gnu.org>.

pcahyna commented at 2019-12-04 11:23:

@jsmeix thank you for your detailed response! So by transitioning to grub-mkstandalone we would lose support for ubuntu 12 on UEFI, other supported distributions should be fine.

jsmeix commented at 2019-12-04 12:54:

Ubuntu 12 is not listed at
https://en.wikipedia.org/wiki/Ubuntu#Releases
which lists as the oldest one Ubuntu 14.04 LTS (released 2014).

The German
https://de.wikipedia.org/wiki/Ubuntu#Zeitleiste
lists Ubuntu 12.04 LTS from 2012 until 2017
(i.e. it is no longer supported since 2017).

So I think for ReaR 2.6 we can reasonably
discontinue support for Ubuntu 12 on UEFI.


[Export of Github issue for rear/rear.]