# PXE UEFI GRUB Booting

Hi, I am trying to setup a PXE environment to boot from network in uefi mode with grub. I use a standalone file embedding this grub.cfg file taken from the Installation Guide

function load_video {
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod all_video
}

insmod gzio

menuentry 'Install Fedora 64-bit'  --class fedora --class gnu-linux --class gnu --class os {
initrdefi f26/initrd.img
}

menuentry 'Install Fedora 26 Server'  --class fedora --class gnu-linux --class gnu --class os {
kernel f26/vmlinuz
}

menuentry 'Rescue installed system'  --class fedora --class gnu-linux --class gnu --class os {
kernel f26/vmlinuz
}


I have previously downloaded the kernel images and initrd in a f26 subfolder of the tftp server root. The result is a correct menu displayed. But when attempting to boot an entry, I get the message : error : invalid filemame f26/vmlinuz The error is the same when I place the vmlinuz directly under the root and change the menuentries accordingly in order to avoid a path in the filename.

What should I do ?

When I use this grub.cfg

menuentry 'Install Fedora 64-bit'  --class fedora --class gnu-linux --class gnu --class os {
insmod net
insmod efinet
insmod tftp

insmod part_gpt
insmod efi_gop
insmod efi_uga
set net_default_server=192.168.1.19

initrd (tftp)/f26/initrd.img
}


I get

Error : destination unreachable when attempting to load the kernel

edit retag close merge delete

What do you mean by "a standalone file embedding this grub.cfg"? Are you loading grub from the tftp server?

I PXE boot UEFI laptops in several locations.

( 2018-03-19 17:59:01 -0600 )edit

I mean a core image of the GRUB including the grub.cfg file that is downloaded from the tftp server.

( 2018-03-20 12:34:22 -0600 )edit

Sort by » oldest newest most voted

I just noticed your other question about making Grub standalone. I would suggest leaving out the grub.cfg file from the combined package and put it on the tftp server instead. Otherwise you might have to tell grub where the root is because it didn't have to find the config file. I have always used the grub efi file from the install ISOs for my setups rather than making my own. Making your own also might not work with secure boot.

Due to me having to support EFI and non-EFI PXE booting and past history I have a certain directory structure, but it is not necessary. You could put all the files in the top tftp directory if you want. In my dhcpd.conf file for the subnet involved, I have (in part):

next-server <tftp server ip address>;
filename "efi/shim.efi";


shim.efi comes from the shim package (or is called BOOTX64.EFI on the live ISO) and is required for secure boot support. You might not need it, but that's the way I have it setup and everything works. In the same directory as the shim.efi, you need to have grubx64.efi which I extracted from a live DVD ISO. Also in that directory you need to have your grub.cfg file. It's just a standard grub.cfg. Again, I copied one from the live ISO and adjusted it for my purposes. Any paths in the grub.cfg are relative to the top of the tftp server directory, not where grub is. Keep it simple and don't use directories at all.

more

Thank you. At first I started that way. But it stopped before displaying the menu (probably unable to find its config). After I embedded grub.cfg the menu appears. Thus my guess is that grub lacks the ability to connect to the network. In fact none of the net commands are available at grub prompt. I am going to do a step back and try again what you advise.

( 2018-03-19 23:38:51 -0600 )edit

I have tried to use shim.efi, shimX64.efi, and grubx64.efi in turn. There were picked up from my /boot/efi/EFI/fedora directory. Each time, changing the dhcpd.conf accordingly, I get :

filename is <the filename="">

filesize is 0 byte

PXE:E23 client received error from server

The only efi executable I am able to download from tftp server is mine i.e. the bootx64.efi standalone I have made.

( 2018-03-20 00:04:51 -0600 )edit

As you have managed to have it working, It would be kind of you to provide me with the grub.cfg file you have used as well as exactly what is the structure of you tftpboot and what each dir/subdir contains?

( 2018-03-20 00:24:39 -0600 )edit

I updated the answer. Hopefully that helps you.

( 2018-03-20 13:30:42 -0600 )edit

Thank you again for your patience. I did what you suggest and which is more or less what the installation guide of Fedora says. I extracted the BOOTX64.EFI and grubx64.efi and put them into a test dir in the tftpboot (the root of the TFTP server). I managed to download GRUB2 but it fails as it is unable to find the linux and initrd commands. Thus I changed them into linuxefi and initrdefi and it works pretty fine. In fact I already found an other way to manage to boot using the grub2-mknetdir command. This command populate the ftpdboot dir with all the necessary stuff. (to follow)

( 2018-03-21 05:12:55 -0600 )edit