Pxegrub2_chainload unable to determine disk containing /EFI/BOOT/BOOTX64.EFI

Problem:
After installing Linux (Tried CentOS7 and Debian 9.5) on a UEFI machine, pxegrub2 chainload to local disk fails.

Expected outcome:
search --file --no-floppy --set=root /EFI/BOOT/BOOTX64.EFI should result in a (hd?,*) device. Currently, $root is empty

Foreman and Proxy versions:
CentOS7: 1.14.3-1

Foreman and Proxy plugin versions:
CentOS7: 1.14.3-1

Other relevant data:
Steps to reproduce:

  1. Configure UEFI on target machine
  2. Install Linux on target machine (Debian 9.5/CentOS 7)
  3. boot target using Network

I’ve compared the pxegrub2_chainload template with the 1.19 version of foreman, they use the same mechanism.

I noticed that the grub search command does not return the disk device on which efi installation exists. As a workaround, I tried this:

menuentry "BTH: Chainload Grub2 EFI from ESP" {
  insmod part_gpt
  insmod fat
  insmod chain

  echo Chainloading Grub2 EFI from ESP, available devices:
  for efi in (*,gpt*)/efi/*/*.efi (*,gpt*)/efi/*/*/*.efi (*,gpt*)/*.efi (*,gpt*)/*/*.efi ; do
    regexp --set=1:efi_device '^\((.*)\)/' "${efi}"
    if [ -e "${efi}" ]; then
      echo "Found efi boot on ${efi} on device ${efi_device}. Attempting efi boot."
      sleep 5
      root=${efi_device}
      chainloader "${efi}"
    fi
  done
}

Has anyone run into this problem?

Our template assumes you only have your OS installed on the first disk (at least ESP is there).

Not sure where did you get your snippet from, this is our version:

I’m using the same snippet as you’ve posted. The OS is deployed on the first available disk. However, the output of the echo found $root statement is:
found
The $root is empty which surprised me. Using the grub menu on an node with debian deployed, I’ve also tried executing the following search statement:
search --file --no-floppy --set=root /EFI/debian/grubx64.efi which results in a successful found disk.

Do all distributions (installed on EFI systems) contain /EFI/BOOT/BOOTX64.EFI?

It is likely there is a bug, most of us use Red Hat compatible systems and I have been testing this only with RHEL and CentOS. Can you list all files of Debians EFI ESP partition?

That was my assumption when I designed this, I can be terribly wrong. We can improve.

I’ve created a tree output for CentOS7 and debian.

Debian9 tree:

# tree /boot/
/boot/
β”œβ”€β”€ config-4.9.0-7-amd64
β”œβ”€β”€ efi
β”‚   └── EFI
β”‚       └── debian
β”‚           └── grubx64.efi
β”œβ”€β”€ grub
β”‚   β”œβ”€β”€ fonts
β”‚   β”‚   └── unicode.pf2
β”‚   β”œβ”€β”€ grub.cfg
β”‚   β”œβ”€β”€ grubenv
β”‚   β”œβ”€β”€ locale
β”‚   β”‚   β”œβ”€β”€ ast.mo
β”‚   β”‚   β”œβ”€β”€ ca.mo
β”‚   β”‚   β”œβ”€β”€ da.mo
β”‚   β”‚   β”œβ”€β”€ de_CH.mo
β”‚   β”‚   β”œβ”€β”€ de@hebrew.mo
β”‚   β”‚   β”œβ”€β”€ de.mo
β”‚   β”‚   β”œβ”€β”€ en@arabic.mo
β”‚   β”‚   β”œβ”€β”€ en@cyrillic.mo
β”‚   β”‚   β”œβ”€β”€ en@greek.mo
β”‚   β”‚   β”œβ”€β”€ en@hebrew.mo
β”‚   β”‚   β”œβ”€β”€ en@piglatin.mo
β”‚   β”‚   β”œβ”€β”€ en@quot.mo
β”‚   β”‚   β”œβ”€β”€ eo.mo
β”‚   β”‚   β”œβ”€β”€ es.mo
β”‚   β”‚   β”œβ”€β”€ fi.mo
β”‚   β”‚   β”œβ”€β”€ fr.mo
β”‚   β”‚   β”œβ”€β”€ gl.mo
β”‚   β”‚   β”œβ”€β”€ hu.mo
β”‚   β”‚   β”œβ”€β”€ id.mo
β”‚   β”‚   β”œβ”€β”€ it.mo
β”‚   β”‚   β”œβ”€β”€ ja.mo
β”‚   β”‚   β”œβ”€β”€ lt.mo
β”‚   β”‚   β”œβ”€β”€ nb.mo
β”‚   β”‚   β”œβ”€β”€ nl.mo
β”‚   β”‚   β”œβ”€β”€ pa.mo
β”‚   β”‚   β”œβ”€β”€ pl.mo
β”‚   β”‚   β”œβ”€β”€ pt_BR.mo
β”‚   β”‚   β”œβ”€β”€ ru.mo
β”‚   β”‚   β”œβ”€β”€ sl.mo
β”‚   β”‚   β”œβ”€β”€ sr.mo
β”‚   β”‚   β”œβ”€β”€ sv.mo
β”‚   β”‚   β”œβ”€β”€ tr.mo
β”‚   β”‚   β”œβ”€β”€ uk.mo
β”‚   β”‚   β”œβ”€β”€ vi.mo
β”‚   β”‚   β”œβ”€β”€ zh_CN.mo
β”‚   β”‚   └── zh_TW.mo
β”‚   β”œβ”€β”€ unicode.pf2
β”‚   └── x86_64-efi
β”‚       β”œβ”€β”€ acpi.mod
β”‚       β”œβ”€β”€ adler32.mod
β”‚       β”œβ”€β”€ affs.mod
β”‚       β”œβ”€β”€ afs.mod
β”‚       β”œβ”€β”€ ahci.mod
β”‚       β”œβ”€β”€ all_video.mod
β”‚       β”œβ”€β”€ aout.mod
β”‚       β”œβ”€β”€ appleldr.mod
β”‚       β”œβ”€β”€ archelp.mod
β”‚       β”œβ”€β”€ ata.mod
β”‚       β”œβ”€β”€ at_keyboard.mod
β”‚       β”œβ”€β”€ backtrace.mod
β”‚       β”œβ”€β”€ bfs.mod
β”‚       β”œβ”€β”€ bitmap.mod
β”‚       β”œβ”€β”€ bitmap_scale.mod
β”‚       β”œβ”€β”€ blocklist.mod
β”‚       β”œβ”€β”€ boot.mod
β”‚       β”œβ”€β”€ bsd.mod
β”‚       β”œβ”€β”€ bswap_test.mod
β”‚       β”œβ”€β”€ btrfs.mod
β”‚       β”œβ”€β”€ bufio.mod
β”‚       β”œβ”€β”€ cat.mod
β”‚       β”œβ”€β”€ cbfs.mod
β”‚       β”œβ”€β”€ cbls.mod
β”‚       β”œβ”€β”€ cbmemc.mod
β”‚       β”œβ”€β”€ cbtable.mod
β”‚       β”œβ”€β”€ cbtime.mod
β”‚       β”œβ”€β”€ chain.mod
β”‚       β”œβ”€β”€ cmdline_cat_test.mod
β”‚       β”œβ”€β”€ cmp.mod
β”‚       β”œβ”€β”€ cmp_test.mod
β”‚       β”œβ”€β”€ command.lst
β”‚       β”œβ”€β”€ configfile.mod
β”‚       β”œβ”€β”€ core.efi
β”‚       β”œβ”€β”€ cpio_be.mod
β”‚       β”œβ”€β”€ cpio.mod
β”‚       β”œβ”€β”€ cpuid.mod
β”‚       β”œβ”€β”€ crc64.mod
β”‚       β”œβ”€β”€ cryptodisk.mod
β”‚       β”œβ”€β”€ crypto.lst
β”‚       β”œβ”€β”€ crypto.mod
β”‚       β”œβ”€β”€ cs5536.mod
β”‚       β”œβ”€β”€ ctz_test.mod
β”‚       β”œβ”€β”€ datehook.mod
β”‚       β”œβ”€β”€ date.mod
β”‚       β”œβ”€β”€ datetime.mod
β”‚       β”œβ”€β”€ diskfilter.mod
β”‚       β”œβ”€β”€ disk.mod
β”‚       β”œβ”€β”€ div.mod
β”‚       β”œβ”€β”€ div_test.mod
β”‚       β”œβ”€β”€ dm_nv.mod
β”‚       β”œβ”€β”€ echo.mod
β”‚       β”œβ”€β”€ efifwsetup.mod
β”‚       β”œβ”€β”€ efi_gop.mod
β”‚       β”œβ”€β”€ efinet.mod
β”‚       β”œβ”€β”€ efi_uga.mod
β”‚       β”œβ”€β”€ ehci.mod
β”‚       β”œβ”€β”€ elf.mod
β”‚       β”œβ”€β”€ eval.mod
β”‚       β”œβ”€β”€ exfat.mod
β”‚       β”œβ”€β”€ exfctest.mod
β”‚       β”œβ”€β”€ ext2.mod
β”‚       β”œβ”€β”€ extcmd.mod
β”‚       β”œβ”€β”€ fat.mod
β”‚       β”œβ”€β”€ file.mod
β”‚       β”œβ”€β”€ fixvideo.mod
β”‚       β”œβ”€β”€ font.mod
β”‚       β”œβ”€β”€ fshelp.mod
β”‚       β”œβ”€β”€ fs.lst
β”‚       β”œβ”€β”€ functional_test.mod
β”‚       β”œβ”€β”€ gcry_arcfour.mod
β”‚       β”œβ”€β”€ gcry_blowfish.mod
β”‚       β”œβ”€β”€ gcry_camellia.mod
β”‚       β”œβ”€β”€ gcry_cast5.mod
β”‚       β”œβ”€β”€ gcry_crc.mod
β”‚       β”œβ”€β”€ gcry_des.mod
β”‚       β”œβ”€β”€ gcry_dsa.mod
β”‚       β”œβ”€β”€ gcry_idea.mod
β”‚       β”œβ”€β”€ gcry_md4.mod
β”‚       β”œβ”€β”€ gcry_md5.mod
β”‚       β”œβ”€β”€ gcry_rfc2268.mod
β”‚       β”œβ”€β”€ gcry_rijndael.mod
β”‚       β”œβ”€β”€ gcry_rmd160.mod
β”‚       β”œβ”€β”€ gcry_rsa.mod
β”‚       β”œβ”€β”€ gcry_seed.mod
β”‚       β”œβ”€β”€ gcry_serpent.mod
β”‚       β”œβ”€β”€ gcry_sha1.mod
β”‚       β”œβ”€β”€ gcry_sha256.mod
β”‚       β”œβ”€β”€ gcry_sha512.mod
β”‚       β”œβ”€β”€ gcry_tiger.mod
β”‚       β”œβ”€β”€ gcry_twofish.mod
β”‚       β”œβ”€β”€ gcry_whirlpool.mod
β”‚       β”œβ”€β”€ geli.mod
β”‚       β”œβ”€β”€ gettext.mod
β”‚       β”œβ”€β”€ gfxmenu.mod
β”‚       β”œβ”€β”€ gfxterm_background.mod
β”‚       β”œβ”€β”€ gfxterm_menu.mod
β”‚       β”œβ”€β”€ gfxterm.mod
β”‚       β”œβ”€β”€ gptsync.mod
β”‚       β”œβ”€β”€ grub.efi
β”‚       β”œβ”€β”€ gzio.mod
β”‚       β”œβ”€β”€ halt.mod
β”‚       β”œβ”€β”€ hashsum.mod
β”‚       β”œβ”€β”€ hdparm.mod
β”‚       β”œβ”€β”€ hello.mod
β”‚       β”œβ”€β”€ help.mod
β”‚       β”œβ”€β”€ hexdump.mod
β”‚       β”œβ”€β”€ hfs.mod
β”‚       β”œβ”€β”€ hfspluscomp.mod
β”‚       β”œβ”€β”€ hfsplus.mod
β”‚       β”œβ”€β”€ http.mod
β”‚       β”œβ”€β”€ iorw.mod
β”‚       β”œβ”€β”€ iso9660.mod
β”‚       β”œβ”€β”€ jfs.mod
β”‚       β”œβ”€β”€ jpeg.mod
β”‚       β”œβ”€β”€ keylayouts.mod
β”‚       β”œβ”€β”€ keystatus.mod
β”‚       β”œβ”€β”€ ldm.mod
β”‚       β”œβ”€β”€ legacycfg.mod
β”‚       β”œβ”€β”€ legacy_password_test.mod
β”‚       β”œβ”€β”€ linux16.mod
β”‚       β”œβ”€β”€ linuxefi.mod
β”‚       β”œβ”€β”€ linux.mod
β”‚       β”œβ”€β”€ loadbios.mod
β”‚       β”œβ”€β”€ loadenv.mod
β”‚       β”œβ”€β”€ loopback.mod
β”‚       β”œβ”€β”€ lsacpi.mod
β”‚       β”œβ”€β”€ lsefimmap.mod
β”‚       β”œβ”€β”€ lsefi.mod
β”‚       β”œβ”€β”€ lsefisystab.mod
β”‚       β”œβ”€β”€ lsmmap.mod
β”‚       β”œβ”€β”€ ls.mod
β”‚       β”œβ”€β”€ lspci.mod
β”‚       β”œβ”€β”€ lssal.mod
β”‚       β”œβ”€β”€ luks.mod
β”‚       β”œβ”€β”€ lvm.mod
β”‚       β”œβ”€β”€ lzopio.mod
β”‚       β”œβ”€β”€ macbless.mod
β”‚       β”œβ”€β”€ macho.mod
β”‚       β”œβ”€β”€ mdraid09_be.mod
β”‚       β”œβ”€β”€ mdraid09.mod
β”‚       β”œβ”€β”€ mdraid1x.mod
β”‚       β”œβ”€β”€ memdisk.mod
β”‚       β”œβ”€β”€ memrw.mod
β”‚       β”œβ”€β”€ minicmd.mod
β”‚       β”œβ”€β”€ minix2_be.mod
β”‚       β”œβ”€β”€ minix2.mod
β”‚       β”œβ”€β”€ minix3_be.mod
β”‚       β”œβ”€β”€ minix3.mod
β”‚       β”œβ”€β”€ minix_be.mod
β”‚       β”œβ”€β”€ minix.mod
β”‚       β”œβ”€β”€ mmap.mod
β”‚       β”œβ”€β”€ moddep.lst
β”‚       β”œβ”€β”€ modinfo.sh
β”‚       β”œβ”€β”€ morse.mod
β”‚       β”œβ”€β”€ mpi.mod
β”‚       β”œβ”€β”€ msdospart.mod
β”‚       β”œβ”€β”€ mul_test.mod
β”‚       β”œβ”€β”€ multiboot2.mod
β”‚       β”œβ”€β”€ multiboot.mod
β”‚       β”œβ”€β”€ nativedisk.mod
β”‚       β”œβ”€β”€ net.mod
β”‚       β”œβ”€β”€ newc.mod
β”‚       β”œβ”€β”€ nilfs2.mod
β”‚       β”œβ”€β”€ normal.mod
β”‚       β”œβ”€β”€ ntfscomp.mod
β”‚       β”œβ”€β”€ ntfs.mod
β”‚       β”œβ”€β”€ odc.mod
β”‚       β”œβ”€β”€ offsetio.mod
β”‚       β”œβ”€β”€ ohci.mod
β”‚       β”œβ”€β”€ part_acorn.mod
β”‚       β”œβ”€β”€ part_amiga.mod
β”‚       β”œβ”€β”€ part_apple.mod
β”‚       β”œβ”€β”€ part_bsd.mod
β”‚       β”œβ”€β”€ part_dfly.mod
β”‚       β”œβ”€β”€ part_dvh.mod
β”‚       β”œβ”€β”€ part_gpt.mod
β”‚       β”œβ”€β”€ partmap.lst
β”‚       β”œβ”€β”€ part_msdos.mod
β”‚       β”œβ”€β”€ part_plan.mod
β”‚       β”œβ”€β”€ part_sun.mod
β”‚       β”œβ”€β”€ part_sunpc.mod
β”‚       β”œβ”€β”€ parttool.lst
β”‚       β”œβ”€β”€ parttool.mod
β”‚       β”œβ”€β”€ password.mod
β”‚       β”œβ”€β”€ password_pbkdf2.mod
β”‚       β”œβ”€β”€ pata.mod
β”‚       β”œβ”€β”€ pbkdf2.mod
β”‚       β”œβ”€β”€ pbkdf2_test.mod
β”‚       β”œβ”€β”€ pcidump.mod
β”‚       β”œβ”€β”€ play.mod
β”‚       β”œβ”€β”€ png.mod
β”‚       β”œβ”€β”€ priority_queue.mod
β”‚       β”œβ”€β”€ probe.mod
β”‚       β”œβ”€β”€ procfs.mod
β”‚       β”œβ”€β”€ progress.mod
β”‚       β”œβ”€β”€ raid5rec.mod
β”‚       β”œβ”€β”€ raid6rec.mod
β”‚       β”œβ”€β”€ random.mod
β”‚       β”œβ”€β”€ read.mod
β”‚       β”œβ”€β”€ reboot.mod
β”‚       β”œβ”€β”€ regexp.mod
β”‚       β”œβ”€β”€ reiserfs.mod
β”‚       β”œβ”€β”€ relocator.mod
β”‚       β”œβ”€β”€ romfs.mod
β”‚       β”œβ”€β”€ scsi.mod
β”‚       β”œβ”€β”€ search_fs_file.mod
β”‚       β”œβ”€β”€ search_fs_uuid.mod
β”‚       β”œβ”€β”€ search_label.mod
β”‚       β”œβ”€β”€ search.mod
β”‚       β”œβ”€β”€ serial.mod
β”‚       β”œβ”€β”€ setjmp.mod
β”‚       β”œβ”€β”€ setjmp_test.mod
β”‚       β”œβ”€β”€ setpci.mod
β”‚       β”œβ”€β”€ sfs.mod
β”‚       β”œβ”€β”€ shift_test.mod
β”‚       β”œβ”€β”€ signature_test.mod
β”‚       β”œβ”€β”€ sleep.mod
β”‚       β”œβ”€β”€ sleep_test.mod
β”‚       β”œβ”€β”€ spkmodem.mod
β”‚       β”œβ”€β”€ squash4.mod
β”‚       β”œβ”€β”€ syslinuxcfg.mod
β”‚       β”œβ”€β”€ tar.mod
β”‚       β”œβ”€β”€ terminal.lst
β”‚       β”œβ”€β”€ terminal.mod
β”‚       β”œβ”€β”€ terminfo.mod
β”‚       β”œβ”€β”€ test_blockarg.mod
β”‚       β”œβ”€β”€ testload.mod
β”‚       β”œβ”€β”€ test.mod
β”‚       β”œβ”€β”€ testspeed.mod
β”‚       β”œβ”€β”€ tftp.mod
β”‚       β”œβ”€β”€ tga.mod
β”‚       β”œβ”€β”€ time.mod
β”‚       β”œβ”€β”€ trig.mod
β”‚       β”œβ”€β”€ tr.mod
β”‚       β”œβ”€β”€ true.mod
β”‚       β”œβ”€β”€ udf.mod
β”‚       β”œβ”€β”€ ufs1_be.mod
β”‚       β”œβ”€β”€ ufs1.mod
β”‚       β”œβ”€β”€ ufs2.mod
β”‚       β”œβ”€β”€ uhci.mod
β”‚       β”œβ”€β”€ usb_keyboard.mod
β”‚       β”œβ”€β”€ usb.mod
β”‚       β”œβ”€β”€ usbms.mod
β”‚       β”œβ”€β”€ usbserial_common.mod
β”‚       β”œβ”€β”€ usbserial_ftdi.mod
β”‚       β”œβ”€β”€ usbserial_pl2303.mod
β”‚       β”œβ”€β”€ usbserial_usbdebug.mod
β”‚       β”œβ”€β”€ usbtest.mod
β”‚       β”œβ”€β”€ verify.mod
β”‚       β”œβ”€β”€ video_bochs.mod
β”‚       β”œβ”€β”€ video_cirrus.mod
β”‚       β”œβ”€β”€ video_colors.mod
β”‚       β”œβ”€β”€ video_fb.mod
β”‚       β”œβ”€β”€ videoinfo.mod
β”‚       β”œβ”€β”€ video.lst
β”‚       β”œβ”€β”€ video.mod
β”‚       β”œβ”€β”€ videotest_checksum.mod
β”‚       β”œβ”€β”€ videotest.mod
β”‚       β”œβ”€β”€ xfs.mod
β”‚       β”œβ”€β”€ xnu.mod
β”‚       β”œβ”€β”€ xnu_uuid.mod
β”‚       β”œβ”€β”€ xnu_uuid_test.mod
β”‚       β”œβ”€β”€ xzio.mod
β”‚       β”œβ”€β”€ zfscrypt.mod
β”‚       β”œβ”€β”€ zfsinfo.mod
β”‚       └── zfs.mod
β”œβ”€β”€ initrd.img-4.9.0-7-amd64
β”œβ”€β”€ lost+found
β”œβ”€β”€ System.map-4.9.0-7-amd64
└── vmlinuz-4.9.0-7-amd64

CentOS7 tree:

# tree /boot/
/boot/
β”œβ”€β”€ config-3.10.0-862.6.3.el7.x86_64
β”œβ”€β”€ efi
β”‚   └── EFI
β”‚       β”œβ”€β”€ BOOT
β”‚       β”‚   β”œβ”€β”€ BOOTX64.EFI
β”‚       β”‚   └── fbx64.efi
β”‚       └── centos
β”‚           β”œβ”€β”€ BOOT.CSV
β”‚           β”œβ”€β”€ BOOTX64.CSV
β”‚           β”œβ”€β”€ fonts
β”‚           β”‚   └── unicode.pf2
β”‚           β”œβ”€β”€ grub.cfg
β”‚           β”œβ”€β”€ grubenv
β”‚           β”œβ”€β”€ grubx64.efi
β”‚           β”œβ”€β”€ mmx64.efi
β”‚           β”œβ”€β”€ shim.efi
β”‚           β”œβ”€β”€ shimx64-centos.efi
β”‚           └── shimx64.efi
β”œβ”€β”€ grub
β”‚   └── splash.xpm.gz
β”œβ”€β”€ grub2
β”‚   └── grubenv -> /boot/efi/EFI/centos/grubenv
β”œβ”€β”€ initramfs-0-rescue-6b17af8b36e6498a86e9e99c01d45921.img
β”œβ”€β”€ initramfs-3.10.0-514.el7.x86_64.img
β”œβ”€β”€ initramfs-3.10.0-862.6.3.el7.x86_64.img
β”œβ”€β”€ initramfs-3.10.0-862.6.3.el7.x86_64kdump.img
β”œβ”€β”€ symvers-3.10.0-862.6.3.el7.x86_64.gz
β”œβ”€β”€ System.map-3.10.0-862.6.3.el7.x86_64
β”œβ”€β”€ vmlinuz-0-rescue-6b17af8b36e6498a86e9e99c01d45921
└── vmlinuz-3.10.0-862.6.3.el7.x86_64

Even on a CentOS7 system, the UEFI chainloading did not succeed as well even though the file efi/EFI/BOOT/BOOTX64.EFI does exist.

I’m no grub expert :frowning: but it seems that the search is unable to determine which device should be used as root.

I had a similar issue with windows 2012 r2 uefi boot and sorted out with the below modification of the template:

   <% paths.each do |path| %>
   elif [ -f ($root)/EFI/<%= path %>/grubx64.efi ]; then
     chainloader ($root)/EFI/<%= path %>/grubx64.efi
   <% end -%>
+  elif [ -f ($root)/EFI/Microsoft/boot/bootmgfw.efi ]; then
+    chainloader ($root)/EFI/Microsoft/boot/bootmgfw.efi
   else
     echo File grubx64.efi not found on ESP.
     echo Update 'pxegrub2_chainload' paths array with:
     ls ($root)/EFI

Does the EFI/Microsoft/boot/ directory contain multiple .efi files?

I only tested this in libvirt VM, do not hesitate to send your patches to our community-templates repo please.

The problem is that grub2 only allows searching volumes by files not directories, that would be easier. I am gonna change that a bit so it tries to find the target EFI file instead of BOOTX64.EFI. I had impression that all OSes have that, I was wrong.

Can you tell me guys what ESP partition label did Windows and Debian OS installer set? We can also search by label too.

Once I have some patches, I’ll share them of course. I can test different HP machines equipped with EFI @ work to see if what works best. If you have patches available, I can help test them if you want.

I’m back in the office tomorrow, I’ll check which label are assigned to the EFI partition for debian.

The efi partition is not formatted with a (vfat) label per se. I’ve checked on CentOS as well as Debian and Arch Linux. I’ll keep digging though. :slight_smile:

This is on my radar, I just have some other duties. In the meantime please file a Redmine issue describing what does not work. Looks like we need to iterate through list of expected files for that search until we find the correct entry.

I’ll create an issue in Redmine for this. While trying different solutions, I now feel like Edison; I’ve found several ways not to chainload efi. :wink:

Sorry for the late answer. Here is the windows 2012 r2 EFI partition content:

PS Y:\EFI\Microsoft\Boot> dir

    Directory: Y:\EFI\Microsoft\Boot

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         10/4/2018   5:54 PM            bg-BG
d----         10/4/2018   5:54 PM            cs-CZ
d----         10/4/2018   5:54 PM            da-DK
d----         10/4/2018   5:54 PM            de-DE
d----         10/4/2018   5:54 PM            el-GR
d----         10/4/2018   5:54 PM            en-GB
d----         10/4/2018   5:54 PM            en-US
d----         10/4/2018   5:54 PM            es-ES
d----         10/4/2018   5:54 PM            et-EE
d----         10/4/2018   5:54 PM            fi-FI
d----         10/4/2018   5:54 PM            fr-FR
d----         10/4/2018   5:54 PM            hr-HR
d----         10/4/2018   5:54 PM            hu-HU
d----         10/4/2018   5:54 PM            it-IT
d----         10/4/2018   5:54 PM            ja-JP
d----         10/4/2018   5:54 PM            ko-KR
d----         10/4/2018   5:54 PM            lt-LT
d----         10/4/2018   5:54 PM            lv-LV
d----         10/4/2018   5:54 PM            nb-NO
d----         10/4/2018   5:54 PM            nl-NL
d----         10/4/2018   5:54 PM            pl-PL
d----         10/4/2018   5:54 PM            pt-BR
d----         10/4/2018   5:54 PM            pt-PT
d----         10/4/2018   5:54 PM            qps-ploc
d----         10/4/2018   5:54 PM            ro-RO
d----         10/4/2018   5:54 PM            ru-RU
d----         10/4/2018   5:54 PM            sk-SK
d----         10/4/2018   5:54 PM            sl-SI
d----         10/4/2018   5:54 PM            sr-Latn-CS
d----         10/4/2018   5:54 PM            sr-Latn-RS
d----         10/4/2018   5:54 PM            sv-SE
d----         10/4/2018   5:54 PM            tr-TR
d----         10/4/2018   5:54 PM            uk-UA
d----         10/4/2018   5:54 PM            zh-CN
d----         10/4/2018   5:54 PM            zh-HK
d----         10/4/2018   5:54 PM            zh-TW
d----         10/4/2018   5:54 PM            Fonts
d----         10/4/2018   5:54 PM            Resources
-a---        10/11/2018   7:22 AM      49152 BCD
-a---          2/7/2018   9:25 AM       5023 boot.stl
-a---        12/14/2017  12:49 AM    1629536 bootmgfw.efi
-a---        12/14/2017  12:49 AM    1625952 bootmgr.efi
-a---        11/21/2014   8:45 PM    1500504 memtest.efi

PS Y:\EFI\Microsoft\Boot>

Thank you for the listing. Do you know if the EFI implementation of Windows 8/10 is similar to Windows 12 r2?

I’ve altered the pxegrub2_chainload snippet which seems to work on both Debian and CentOS deployed systems (testing on virtual machines and physical HP machines). @lzap: Can you review the snippet?

<%#
kind: snippet
name: pxegrub2_chainload
model: ProvisioningTemplate
snippet: true
%>
menuentry 'Chainload Grub2 EFI from ESP' --id local {
  insmod part_gpt
  insmod fat
  insmod chain

  for efi in (*,gpt*)/efi/*/*.efi (*,gpt*)/efi/*/*/*.efi (*,gpt*)/*.efi (*,gpt*)/*/*.efi ; do
    regexp --set=1:efi_device '^\((.*)\)/' "${efi}"
    regexp --set=1:efi_path '(.*)/.*$' "${efi}"
    regexp --set=1:efi_file '.*\/(.*)$' "${efi}"

    if [ "$efi_file" == "grubx64.efi" ]; then
      set root=$efi_device
      set efi_found=true
      break
    fi
    if [ "$efi_file" == "bootmgfw.efi" ]; then
      set root=$efi_device
      set efi_found=true
      break
    fi
  done

  echo "Found efi boot on $efi_path/$efi_file"
  sleep 2

  if [ -f $efi_path/$efi_file ]; then
    chainloader $efi_path/$efi_file
  else
    echo File grubx64.efi nor bootmgfw.efi not found on ESP.
    echo Update 'pxegrub2_chainload' paths array with:
    ls ($root)/EFI
    echo The system will halt in 2 minutes or
    echo press ESC to halt immediately.
    sleep -i 120
    halt --no-apm
  fi
}

menuentry 'Chainload into BIOS bootloader on first disk' --id local_chain_hd0 {
  set root=(hd0,0)
  chainloader +1
}

menuentry 'Chainload into BIOS bootloader on second disk' --id local_chain_hd1 {
  set root=(hd1,0)
  chainloader +1
}

If this provides a working solution, what do I need to do in order to add this to future foreman releases?

1 Like

I’m not sure. I never deployed Windows 8/10 using foreman but I think you can check EFI partition using β€œdiskpart” command if you use windows 8/10 on your laptop/pc.

Awesome! Would Grub2 pick also regular shell syntax of:

if [ "$efi_file" == "grubx64.efi" -o "$efi_file" == "bootmgfw.efi" ]; then

Also we want to search for shim.efi as well (actually as first), on Red Hats this is the signed shim which then loads (unsigned) Grub2. The question is if this will work in SecureBoot mode, we need to test.

But overall this is great improvement. Feel free to file PR into community templates so I can review and test from there.

I’ve made a mistake when creating an issue in the redmine for foreman. Bug #25185: Pxegrub2_chainload unable to determine disk containing /EFI/BOOT/BOOTX64.EFI - Templates - Foreman is under project templates and should be under project Foreman. How do I move the issue from project Templates to Foreman?

I’ve moved it for you.

Thank you very much.