This post is a continuation of our previous investigation around PXE servers capable of deploying operating systems (i.e. Ubuntu) through the network to BIOS or UEFI based systems. The standard approach in order to deploy BIOS or UEFI based systems is to use a combination of pxelinux files and grub files. This combination seems to cover most of the scenarios and working almost all the time. Such setup has been described in the following post
Then, some users have been requesting a post about setting up a PXE server and use exclusively pxelinux files. After some investigations, we have been able to setup such PXE server. The bid downside of such approach is that the UEFI pxelinux files are not signed. This means that you cannot use this configuration to deploy Operating systems on UEFI based systems where secure boot is enabled. The other real problem is the performance issue encountered so far. Based on the version of pxelinux used, you can have immediate error or you can have some success. However, compared to the grub solution, booting time when using UEFI version of pxelinux is really really slow (it takes several minutes to get the Ubuntu installer)
This post will provide some guidance in order to replace the pxelinux files and use exclusively the grub files. The grub files will be used to deploy OS against BIOS or UEFI Based systems. As you will see, the process is quite straight forward and seems to work quite well.
So, let’s go !
To be able to use this guide, you will need to first follow the instructions in our previous post as it explains how to setup the full TFTP/PXE infrastructure. We will not repeat here all the steps already provided. The following assumptions have been made as well
- Hyper-v platform is used to emulated UEFI based virtual machines
- VM Generation 2 will be used in order to have UEFI and SecureBoot option is enabled (grub file support such functionality)
- You have internet connection in order to download additional necessary packages
- You have followed the instructions from our previous post to install DHCP/PXE/TFTP and create the tftp folder structure
Step by Step Guide
Step 1 – Download UEFI PXELINUX Files
Because we have installed on Ubuntu Server as UEFI where Secure boot is enabled, the machine is hosting only the efi version of the grub files. So, before proceeding, we need to download the correct version of grub files (the one for Bios version). To download the needed packages, we will execute the following command
sudo apt-get install grub-pc
Step 2 – Generate the grub boot loader for bios systems
Actually, while searching for this information, we have discovered that some commands exists to create the grub files needed for pxe servers. In this post, we will focus on generating the bios boot loader that will be used by grub. So, to generate such file, you should run the following command
cd ~ grub-mkimage -d /usr/lib/grub/i386-pc/ -O i386-pc-pxe -o ./booti386 -p '/grub' pxe tftp
This command will generate the booti386 file in the folder location where you execute the command
If you have followed the installation instructions described here, you have already the necessary tftp folder structure in place and you have also the necessary grub bootloaders files for uefi systems
We can create the uefi version by executing the following command
grub-mkimage -d /usr/lib/grub/x86_x64/ -O x86_x64-efi -o ./bootx64.efi -p '/grub' efinet tftp
grub-mkimage -d /usr/lib/grub/x86_x64/ -O x86_x64-efi.signed -o ./bootx64.efi -p '/grub' efinet tftp
to support secure boot feature of UEFI systems
Step 3 – Copy all necessary files under the tftp folder structure
We are almost done. Indeed, we have already the tftp folder structure in place. We simply need to copy the necessary files in the correct location. The first thing to do is to copy the grub bios boot loader file (i.e. booti386) under the tftp root folder by issuing the following command
copy ~/booti386 t-/tftp/
Then, we also need to copy some grub files under the the tftp subfolder. So, execute the following command
sudo cp -rf /usr/lib/grub/i386-pc /tftp/grub
There is no need to update the grub.cfg file as both boot loaders will be using the same file with the same configuration information.
Step 4 – update your dnsmasq.conf file
The pxe client needs to know where to find the file it will boot from. In our previous post, we have been using the pxelinux software file and we have made a reference of it in the /etc/dnsmasq.conf. So, because we want to use the booti386 instead of the pxelinux.0 file, we will comment the last line of the file and we have added the following line
So, the /etc/dnsmasq.conf file needs to be modified as follow (comment the line in red and add the line in green in your config file)
#Interface information #--use ip addr to see the name of the interface on your system interface=eth0,lo bind-interfaces domain=c-nergy.local #-------------------------- #DHCP Settings #-------------------------- #-- Set dhcp scope dhcp-range=192.168.1.160,192.168.1.200,255.255.255.0,2h #-- Set gateway option dhcp-option=3,192.168.1.1 #-- Set DNS server option dhcp-option=6,192.168.1.1 #-- dns Forwarder info server=188.8.131.52 #----------------------# # Specify TFTP Options # #----------------------# #--location of the pxeboot file #dhcp-boot=/bios/pxelinux.0,pxeserver,192.168.1.150 dhcp-boot=/booti386,pxeserver,192.168.1.150 #--enable tftp service enable-tftp #-- Root folder for tftp tftp-root=/tftp #--Detect architecture and send the correct bootloader file dhcp-match=set:efi-x86_64,option:client-arch,7 dhcp-boot=tag:efi-x86_64,grub/bootx64.efi
Test & Validate your setup
Time to test our setup. We have been performing a test using a physical Bios based system and on Virtualbox virtual machines. These tests were successful and you should see the grub menu when booting your bios system.
Click on picture for better resolution
However, when performing the test on an virtual machine hosted on hyper-v hypervisor, the grub menu never shows up….(see screenshot below)
Click on picture for better resolution
This is it for this post ! This one is not that long and has been written to provide complete options when configuring a pxe server. Based on our investigations, it’ seems that the best configuration options for PXE Servers is to combine pxelinux files (to pxeboot bios based systems) and use grub files for uefi based systems.
The second best option would be to use a PXE server that would be using exclusively grub technology to perform pxeboot operations. The PXE erver can be configured to boot Bios and uefi bases system using only grub files (as described in this post). The only limitation is when booting Hyper-V VMS.
The least appealing options would be configure your PXE server to use exclusively pxelinux files. The pxelinus files for BIOS based systems are working great but the UEFI version seems not ready for prime time. Performance issues, unsigned file preventing deployment on system configured with secure boot enabled makes uefi pxelinux files unusable for real deployment scenarios.
Personally, I like the idea of using only grub files because it offers a consistent look and feel when performing the deployment operation. Moreover, grub offers also the possibility to customize the boot menu a little bit further with a background image but this is not part of this post
Hope you enjoyed this deep dive in PXE technology for Linux
Till next time