In this article, we’ll be discussing how to automatically load the Grub2 Config file for EFI boot via PXE. This process can be a bit tricky, but with the right guidance, you can accomplish it with ease. Let’s get started!
To automatically load the Grub2 Config file for EFI boot via PXE, you need to edit the
grub.cfg file and add the necessary lines to check and source the file. Additionally, you need to set the GRUB prefix to the correct TFTP server root and specify the default menu entry. Ensure your DHCP server is correctly configured and check for any potential GRUB version bugs.
What is PXE Boot?
PXE (Preboot eXecution Environment) is a protocol that allows a computer to boot from a network server before its operating system loads. This is particularly useful in enterprise environments where a large number of computers need to be set up with the same system image.
What is GRUB2 and EFI?
GRUB2 (GRand Unified Bootloader version 2) is the default bootloader for many Linux distributions. It’s responsible for loading the operating system kernel from the disk and starting it up.
EFI (Extensible Firmware Interface) is a type of firmware that initializes the hardware components of a computer during the startup process, before the operating system begins to load. EFI boot is a boot method which uses EFI firmware to start the computer.
Setting Up Your Environment
Before we begin, ensure that your
grub.cfg file is located in the correct directory on the TFTP server. This should be the same directory as the
Editing the Grub.cfg File
grub.cfg file and add the following lines at the beginning:
if [ -e $prefix/grub.cfg ]; then
This code checks if the
grub.cfg file exists in the same directory as the GRUB prefix (
$prefix) and sources it if it does. The
source command in GRUB2 reads in the contents of the specified file and treats them as though they were directly included in the place of the
Setting the GRUB Prefix
The GRUB prefix is a variable that points to the directory containing the GRUB files. You can set the
prefix variable in GRUB to point to the correct TFTP server root by running the following command in the GRUB console:
grub> set prefix=(tftp,x.x.x.x)/
x.x.x.x with the IP address of your TFTP server. The
set command is used to assign a value to a variable in GRUB.
Setting the Default Menu Entry
You can set the
default variable in GRUB to specify the default menu entry to boot. Add the following line to your
This sets the first menu entry as the default option. The
default variable in GRUB determines which menu entry is selected when GRUB boots.
After making these changes, save your
grub.cfg file and try booting again. GRUB should now automatically load the config file and boot Windows.
If you’re still experiencing issues, ensure that your DHCP server is correctly configured to provide the PXE server IP address as the TFTP server option (option 66). You can refer to the DHCP configuration guide for more information.
Also, check for any potential bugs in your GRUB version that might be causing the problem. The GRUB bug tracker can be a good resource for this.
In this article, we’ve covered how to automatically load the Grub2 Config file for EFI boot via PXE. This process involves editing the
grub.cfg file, setting the GRUB prefix and default variables, and correctly configuring your DHCP server. With these steps, you should be able to boot your system over the network using PXE and GRUB2.
grub.cfg file is a configuration file for GRUB2 that contains the settings and options for the bootloader. It determines which operating systems and kernels are available to boot and allows customization of the boot menu.
grub.cfg file should be located in the same directory as the
grub.efi file on the TFTP server. Make sure they are in the correct directory for the PXE boot process to locate and load the configuration file.
To set the default menu entry in GRUB2, you can use the
set default="0" command in the
grub.cfg file. This sets the first menu entry as the default option. You can adjust the number to match the desired menu entry.
The GRUB prefix is a variable that points to the directory containing the GRUB files. It is used to specify the location of the GRUB configuration and modules. Setting the prefix correctly is crucial for GRUB to locate and load the necessary files during the boot process.
To check if your DHCP server is correctly configured for PXE boot, ensure that it is providing the PXE server IP address as the TFTP server option (option 66). You can use network monitoring tools or check the DHCP server logs to verify if the correct IP address is being assigned to the clients during the boot process.