#2013 PR merged: Error out when we cannot make a bootable EFI image of GRUB2 (issue 1193)

Labels: enhancement, fixed / solved / done

jsmeix opened issue at 2019-01-07 14:11:

Without /usr/lib/grub2/x86_64-efi/moddep.lst (excerpts):

# mv /usr/lib/grub2/x86_64-efi/moddep.lst /usr/lib/grub2/x86_64-efi/moddep.lst.away

# usr/sbin/rear -D mkrescue
...
Using UEFI Boot Loader for Linux (USING_UEFI_BOOTLOADER=1)
...
Trying to find what to use as UEFI bootloader...
Trying to find a 'well known file' to be used as UEFI bootloader...
Using '/boot/efi/EFI/opensuse/grubx64.efi' as UEFI bootloader file
...
Created initrd.cgz with gzip default compression (69492491 bytes) in 9 seconds
ERROR: grub2-mkimage would not make bootable EFI image of GRUB2 (no /usr/lib/grub*/x86_64-efi/moddep.lst file)
Some latest log messages since the last called script 250_populate_efibootimg.sh:
  2019-01-07 14:56:06.723473419 Entering debugscripts mode via 'set -x'.
  mkdir: created directory '/tmp/rear.VgRH5w8InHHhFjJ/tmp/mnt'
  mkdir: created directory '/tmp/rear.VgRH5w8InHHhFjJ/tmp/mnt/EFI'
  mkdir: created directory '/tmp/rear.VgRH5w8InHHhFjJ/tmp/mnt/EFI/BOOT'
  mkdir: created directory '/tmp/rear.VgRH5w8InHHhFjJ/tmp/mnt/EFI/BOOT/fonts'
  mkdir: created directory '/tmp/rear.VgRH5w8InHHhFjJ/tmp/mnt/EFI/BOOT/locale'
  '/boot/efi/EFI/opensuse/grubx64.efi' -> '/tmp/rear.VgRH5w8InHHhFjJ/tmp/mnt/EFI/BOOT/BOOTX64.efi'
  /root/rear.github.master/usr/share/rear/lib/_input-output-functions.sh: line 331: type: grub-mkimage: not found
Aborting due to an error, check /root/rear.github.master/var/log/rear/rear-g243.log for details
Exiting rear mkrescue (PID 10957) and its descendant processes
Running exit tasks
You should also rm -Rf /tmp/rear.VgRH5w8InHHhFjJ
Terminated

With /usr/lib/grub2/x86_64-efi/moddep.lst (excerpts):

# mv /usr/lib/grub2/x86_64-efi/moddep.lst.away /usr/lib/grub2/x86_64-efi/moddep.lst

# usr/sbin/rear -D mkrescue
...
Using UEFI Boot Loader for Linux (USING_UEFI_BOOTLOADER=1)
...
Trying to find what to use as UEFI bootloader...
Trying to find a 'well known file' to be used as UEFI bootloader...
Using '/boot/efi/EFI/opensuse/grubx64.efi' as UEFI bootloader file
...
Created initrd.cgz with gzip default compression (69492853 bytes) in 9 seconds
Making ISO image
Wrote ISO image: /root/rear.github.master/var/lib/rear/output/rear-g243.iso (113M)
Copying resulting files to nfs location
Saving /root/rear.github.master/var/log/rear/rear-g243.log as rear-g243.log to nfs location
Copying result files '/root/rear.github.master/var/lib/rear/output/rear-g243.iso /tmp/rear.4s0ZKWq4YxvVB6x/tmp/VERSION /tmp/rear.4s0ZKWq4YxvVB6x/tmp/README /tmp/rear.4s0ZKWq4YxvVB6x/tmp/rear-g243.log' to /tmp/rear.4s0ZKWq4YxvVB6x/outputfs/g243 at nfs location
Exiting rear mkrescue (PID 25791) and its descendant processes
Running exit tasks
You should also rm -Rf /tmp/rear.4s0ZKWq4YxvVB6x
  • Brief description of the changes in this pull request:

Now it errors out directly in the 'build_bootx86_efi' function if

  1. neither grub-mkimage nor grub2-mkimage is found
  2. no /usr/lib/grub*/x86_64-efi/moddep.lst file is found
  3. grub-mkimage or grub2-mkimage results non-zero exit code

The build_bootx86_efi function is only called in
output/ISO/Linux-i386/250_populate_efibootimg.sh
which runs only if UEFI is used so that we simply error out
in that function if we cannot make a bootable EFI image of GRUB2.
Normally a function should not exit out but return to its caller with
various appropriate non-zero return codes depending on each error.

jsmeix commented at 2019-01-07 14:13:

@rmetrich @gdha
could you please test it on Red Hat and Fedora systems?

@gozora
could you please have a general look because it is about GRUB2 bootloader stuff?


[Export of Github issue for rear/rear.]