Red Hat Bugzilla – Bug 1211101
grub2 fw_path variable is incorrect for x86 EFI network boot: too many path components stripped
Last modified: 2015-11-19 07:23:55 EST
Description of problem: As of grub2-2.02-0.16, GRUB tries both $fw_path/grub.cfg-* and $prefix/grub.cfg-* when looking for its config file on a network book (bug 1148652). However on x86 EFI, $fw_path is incorrect and thus GRUB searches the wrong path. Version-Release number of selected component (if applicable): grub2-2.02-0.16.el7.x86_64 grub2-efi-modules-2.02-0.16.el7.x86_64 Steps to Reproduce: 1. Set up a TFTP server with the GRUB2 config and image (symlink) in a subdirectory two levels deep: yum install tftp-server grub2-efi-modules grub2-mknetdir -d /usr/lib/grub/x86_64-efi --net-directory /var/lib/tftpboot mkdir -p /var/lib/tftpboot/bootloader/test5 ln -s ../../boot/grub2/x86_64-efi/core.efi /var/lib/tftpboot/bootloader/test5/image cat >/var/lib/tftpboot/bootloader/test5/grub.cfg <<"EOF" # put something here, doesn't really matter EOF systemctl start tftp.socket 2. Find an x86 EFI system, configure its DHCP with next-server=<yourtftpserver> filename=bootloader/test5/image, boot it up Actual results: GRUB looks for its config under /bootloader/grub.cfg-* then /boot/grub2/grub.cfg-* Expected results: GRUB should look for its config under /bootloader/test5/grub.cfg-* then /boot/grub2/grub.cfg-* Additional info: You can see GRUB's attempts to load its config if you add -vv to the TFTP server: Apr 13 11:30:24 lab in.tftpd[17886]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-01-f0-92-1c-de-38-de Apr 13 11:30:24 lab in.tftpd[17886]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17887]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A40195E Apr 13 11:30:24 lab in.tftpd[17887]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17888]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A40195 Apr 13 11:30:24 lab in.tftpd[17888]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17889]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A4019 Apr 13 11:30:24 lab in.tftpd[17889]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17890]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A401 Apr 13 11:30:24 lab in.tftpd[17890]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17891]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A40 Apr 13 11:30:24 lab in.tftpd[17891]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17892]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A4 Apr 13 11:30:24 lab in.tftpd[17892]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17893]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0A Apr 13 11:30:24 lab in.tftpd[17893]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17894]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg-0 Apr 13 11:30:24 lab in.tftpd[17894]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17895]: RRQ from 10.64.25.94 filename /bootloader/grub.cfg Apr 13 11:30:24 lab in.tftpd[17895]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17896]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-01-f0-92-1c-de-38-de Apr 13 11:30:24 lab in.tftpd[17896]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17897]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A40195E Apr 13 11:30:24 lab in.tftpd[17897]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17898]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A40195 Apr 13 11:30:24 lab in.tftpd[17898]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17899]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A4019 Apr 13 11:30:24 lab in.tftpd[17899]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17900]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A401 Apr 13 11:30:24 lab in.tftpd[17900]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17901]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A40 Apr 13 11:30:24 lab in.tftpd[17901]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17902]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A4 Apr 13 11:30:24 lab in.tftpd[17902]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17903]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0A Apr 13 11:30:24 lab in.tftpd[17903]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17904]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg-0 Apr 13 11:30:24 lab in.tftpd[17904]: sending NAK (1, File not found) to 10.64.25.94 Apr 13 11:30:24 lab in.tftpd[17905]: RRQ from 10.64.25.94 filename /boot/grub2/grub.cfg Apr 13 11:30:24 lab in.tftpd[17905]: sending NAK (1, File not found) to 10.64.25.94
I had a poke around in GRUB's source. This is using the prepped sources from grub2-2.02-0.16.el7. The fw_path variable is populated using the path returned from grub_machine_get_bootlocation. The EFI version of grub_machine_get_bootlocation grabs the path from either grub_efi_get_filename (if booted from disk) or grub_efi_net_config (if booted from the network) and then strips the last component from the path. However grub_efi_net_config populates the path using grub_net_configure_by_dhcp_ack which *also* strips the last component from the path.
Created attachment 1013793 [details] grub2 patch The attached patch appears to fix the problem.
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://rhn.redhat.com/errata/RHSA-2015-2401.html