Ubuntu – Setup PXE Server using pxelinux files only (Bios & UEFI Support)

Hello World, 

This post is a continuation of our previous post about setting up a PXE Server that can be used to deploy BIOS or UEFI Based systems.  Our PXE Server setup has been using the pxelinux files for the bios client and the grub software to boot UEFI client.  As mentioned in the previous post, this configuration seems the best option nowadays because the pxelinux files are not signed for secure boot in UEFI and thus have a limited interest in production environment.  

However, some people have been requesting and asking if it would be possible to use only PXELINUX files to support BIOS and UEFI based systems.  This post will investigate this option and provide a quick step by step instructions. So, let’s see if this is a viable solution…. 

Overview

Assumptions 

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 Disabled (because pxelinux uefi are not supported when secure boot is enabled)
  • 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

So, the first step is to obtain the necessary pxelinux files. The version of pxelinux that you will be using is really important.  We have tried the latest version of the package but this one didn’t worked at all.  We had an error message about packet size issue.  So, we had to downgrade and select another package. We have download the previous version (i.e. 6.03-pre9). So, in your Ubuntu server, in your console, execute the following commands 

cd ~
wget https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/Testing/6.03/syslinux-6.03-pre9.tar.xv

 

After downloading it, we can extract the content of the compressed file by executing the following command 

tar -xf ~/syslinux-6.03-pre9.tar.xv

 

Step 2 – copy the pxelinux uefi files to the correct location

It’s time to copy the files to the correct location.  Before doing this, we will create a new subfolder under our /tftp root folder.  We will create the /tftp/uefi folder that would be used to host the pxelinux UEFI files needed.  So, as a first step, we will execute the following command 

sudo mkdir /tftp/uefi 

Now, we can copy the necessary pxelinux files into the proper location. 

sudo cp ~/syslinux-6.03-pre9/efi64/com32/elflink/ldlinux/ldlinux.e64 /tftp/uefi
sudo cp ~/syslinux-6.03-pre9/efi64/com32/libutil/libutil.c32 /tftp/uefi 
sudo cp ~/syslinux-6.03-pre9/efi64/com32/menu/menu.c32 /tftp/uefi
sudo cp ~/syslinux-6.03-pre9/efi64/com32/menu/vesamenu.c32 /tftp/uefi
sudo cp ~/syslinux-6.03-pre9/efi64/efi/syslinux.efi /tftp/uefi

 

Step 3 – create the pxelinux boot menu

Here again, nothing new. we need to create the proper folder structure so the pxe boot loader knows where to get the necessary files.  We will first create an additional subfolder under /tftp/uefi called pxelinux.cfg.  So, execute the following command 

sudo mkdir /tftp/uefi/pxelinux.cfg

We can now copy the file for the boot menu from the bios folder.  We will issue the following command 

sudo cp /tftp/bios/pxelinux.cfg/default /tftp/uefi/pxelinux.cfg 

Step 4 – Create symbolic link to boot folder 

We are almost done with the folder structure preparations.  We now need to create a symbolic link to the /tftp/boot folder so the pxelinux boot loader knows where to find the necessary files to boot from.  To create this symbolic link, you will simply execute the following command 

sudo ln -s /tftp/boot  /tftp/uefi/boot

Step 5 – Update the 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 grub software file and we have made a reference of it in the /etc/dnsmasq.conf.  So, because we want to use the syslinux.efi instead of the bootx64.efi file, we will comment the last line of the file and we have added the following line 

dhcp-boot=tag:efi-x86_64,uefi/syslinux.efi

 

#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=8.8.8.8

#----------------------#
# Specify TFTP Options #
#----------------------#

#--location of the pxeboot file
dhcp-boot=/bios/pxelinux.0,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
dhcp-boot=tag:efi-x86_64,uefi/syslinux.efi

To have the change applied to your system, you will need to restart the dnsmasq service.  To perform such task, you will execute the following command 

sudo systemctl restart dnsmasq

Then, you should check that the dnsmasq is started correctly and that no errors are reported by issuing the command 

sudo systemctl status dnsmasq

 

Step 6 – Try to boot your PXE client 

Before trying your pxe uefi boot solution, you will need to ensure that you have disabled the secure boot option in your virtual machine (see screenshot below). If you have enabled the secure boot, the pxe boot process will fail immediately (when using uefi pxelinux files !!!!) 

Click on picture for better resolution 

If your virtual machine is configured correctly, you should see the pxelinux menu (with some noise in the background) and you should be able to boot from network. 

Click on picture for better resolution 

Important !  The performance are really bad with these files.  The BIOS version will boot in a few seconds. The UEFI process might take several minutes before you see the server wizard installer or the Ubuntu desktop live file system and perform your installation 

Click on picture for better resolution 

Final Notes 

This is it for this post !  After a lot of trial an error, we succeeded in implementing a pxe server using only pxelinux technology. However, because of the limitations and performance issues we have encountered with the uefi version of pxelinux file, this pxelinux solution only will probably never be used in a production infrastructure.  The uefi pxelinux does not support uefi machines with secure boot enabled and the download process of the 40 MB initial boot files take multiple minutes.  For us, it’s a no go ! 

To complete this serie about pxe server and linux, we might want to investigate the option to have a pxe server using only grub files….. we will see if we have time to do that… but at the moment we are really busy working on other topics, so we will see 

Till next time 

See ya

 

 

3 thoughts on “Ubuntu – Setup PXE Server using pxelinux files only (Bios & UEFI Support)

  1. step 2 you created a directory that you never use /tftp/boot/uefi so I think you meant /tftp/uefi

  2. @DayBreak,

    You are correct… we will update the post 🙂 Thank you for providng positive feedback
    Till next time
    See ya

Leave a Reply