Hello World,
Lately, we have received lately a few questions/requests about Ubuntu 24.04 and PXE boot capability. In some previous posts, we have demonstrated how to boot Ubuntu Desktop Edition through the PXE technology. If we look at the last post we have published about PXE and Ubuntu, it is indeed some time ago. The post was covering Ubuntu 20.04 Desktop and Server Edition. Since this post, we never updated and provided new information about PXE deployment and recent Ubuntu releases.
This post will provide an update on how to deploy Ubuntu 24.04 Desktop Edition through the network and the PXE technology. So, let’s see how does it work with Ubuntu 24.04 !
Overview
This guide will describe the necessary steps needed in order to deploy Ubuntu 24.04 Desktop through the network using PXE technology. To deploy operating systems through PXE technology, there are some server roles and services that needs to be present on the network. PXE deployments relies on DHCP,DNS, TFTP, File and Web Services. In this post, we will prepare the infrastructure needed to have PXE capabilities. This setup guide will allow the deployment of Ubuntu 24.04 Desktop Edition to UEFI or Bios based systems.
Note : If you need to deploy previous operating system (Ubuntu 20.04 or Ubuntu 22.04), we recommend you to review our previous post here
Step by Step Guide
Assumptions
The following assumptions have been made in order to have this scenario working
- You have internet connection in order to download additional necessary packages
- You have Ubuntu 24.04.1 Desktop ISO or installation files
- The PXE Server will be hosted on Ubuntu 24.04 Desktop (can be minimal or full version)
- Our virtual plaftorm is based on Hyper-V Server
- VM Generation 2 will be used in order to have UEFI and SecureBoot option is Enabled (detailed instruction can be found here)
Step 0 – Installing Ubuntu 24.04 Desktop
We will need to have a “PXE Server” deployed on the network. In our scenario, an Ubuntu 24.04.x Desktop system will be used. This machine will host the necessary services needed to deploy operating system through network. Obviously, you could have used Ubuntu Server Edition as the steps and processes are quite similar. Be sure that Ubuntu 24.04 Desktop has the latest updates installed.
Step 1 – Download necessary packages
In this post, we assume that the Ubuntu Desktop 24.04 will be hosting all the necessary services needed to implement a proper PXE Infrastructure. To setup a PXE infra, we need to install the following packages
- dnsmasq (providing DHCP,DNS and TFTP services),
- apache web for storage purposes and
- NFS packages if you are planning to deploy Ubuntu Desktop through your PXE infrastructure.
Step 1.1 – Install apache web server
To install the apache package, you will issue the following command
sudo apt-get install apache2
Step 1.2 – Install NFS packages
NFS packages will provide file services capabilities. To install the nfs packages, execute the following commands
sudo apt-get install nfs-kernel-server
Step 1.3 – Install dnsmasq packages
To install the dnsmasq package, you will issue the following command
sudo apt-get install dnsmasq
During the installation, you will see some errors and warnings. At this stage, this is an expected behavior. Additional configuration will be needed at later stage
Click on Picture for Better Resolution
Step 1.4 –Download pxelinux Packages
We will first download the PXELinux package from the web site creator
cd ~/Downloads/ wget https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.zip unzip syslinux-6.03.zip
Step 1.5 –Download “UEFI” Packages
The commands below basically will download the necessary signed bootloader files and grub files needed by PXE server and extract the contents on their dedicated folders (shim and grub). These files are needed to pxeboot uefi clients…..
cd ~/Downloads/ apt-get download shim.signed dpkg -x <%name of deb package%> shim apt-get download grub-efi-amd64-signed dpkg -x <%name of deb package%> grub
Step 2 – Setup Static IP Address
Usually, Ubuntu installation are using dynamic ip addresses (DHCP). We will move from the dynamic configuration to a static configuration. To perform such operation, you will click on the network icon on the right side of the top bar > expand the wired connected and select wired settings
Click on Picture for better Resolution
In the right pane, click the gear to open the properties pages. Then, go to the IPv4 tab
Click on Picture for better Resolution
Change from Automatic to Dynamic and set the necessary ip address information. Press the Apply button and you are back to the network settings page
To effectively apply the changes, you have to disable and re-enable the network by using the slider button (or you can reboot the computer)
Click on Picture for better Resolution
To check that the correct ip address has been set, you can open the terminal console and issue the following command ip a.
Step 3 – Create the TFTP Folder Structure
We will create a folder called tftp at root of the filesystem (/tftp). Within this folder, the following structure will be create
tftp |-bios |-boot |-grub
To create this structure, you will need to execute the following commands in your Terminal Console
sudo mkdir /tftp sudo mkdir /tftp/bios sudo mkdir /tftp/boot sudo mkdir /tftp/grub
Step 4 – Create the web Folder Structure
Because you are using the Apache Web server, we will be copying all sources files under /var/www/html directory. We will copy the iso files contents of Ubuntu 24.04 Desktop and Ubuntu Server under this location.
Our structure will look like the following representation. Obviously, you can create your own structure
var |-www |-html |-desktop |-u2404 |-u2204 |- ...
To create the following folder structure, you can use the following commands in a Terminal Console
sudo mkdir /var/www/html/desktop/ sudo mkdir /var/www/html/desktop/u2404 sudo mkdir /var/www/html/desktop/u2204
Step 5 – Populate the web folder structure
So, mount your iso file into your Ubuntu PXE machine. To mount it, issue the following command
sudo mount /dev/sr0 /media
Copy the files from the iso image into the correct directory. You can use the following syntax to perform the operation
sudo cp -rf <%Your Path To Install Files%>/* /var/www/html/desktop/u2404 example : sudo cp -rf /media/* /var/www/html/desktop/u2404
The command below is copying all the contents of the source cdrom except a hidden folder which is needed to have the pxe process working as expected. So, you have to run an additional command in order to ensure that all the files you need have been copied accordingly. From a Terminal Console, issue the following command
sudo cp -rf <%Your Path To Install Files%>/.disk /var/www/html/desktop/u2404
example : sudo cp -rf /media/cdrom_Name/.disk /var/www/html/desktop/u2404
When the copy is finished, unmount the iso/DVD image from your machine by issuing the following command
sudo umount /media
You can check that your files have been copied accordingly by browsing to /var/www/html/desktop/xxxx.
Step 6 – Configuring your NFS Server Settings
Since our folder structure is ready, we can start configuring the different services that are used by the PXE server. To ensure that our directory structure is accessible through the network and through the nfs protocol, we will need to edit the following file by issuing the following command
sudo nano /etc/exports
Insert at the bottom of the file, the path where you have stored your installation files, which subnet can access it and which kind of right you want to grant. In our scenario, we want to grant access to the following directory /var/www/html/desktop through the network subnet 192.168.1.0/24 and we are granting read only access (ro). So, at the end of the file, we would add the following line
/var/www/html/desktop 192.168.1.0/24(ro)
When this has been done, it’s time to restart the nfs service. To do that, you simply execute the following command
sudo systemctl restart nfs-kernel-server
Step 7 – Configuring the dnsmasq service
Almost there ! Now, we need to configure the dnsmasq service which will provide the glue between the different services. dnsmasq configuration file will be used to provide the necessary information to the pxe client when it boots. This file will dictate where to look for pxe bootloader based on the client architecture (uefi or bios). So, let’s edit the /etc/dnsmasq.conf file and at the bottom add the following information
To edit the configuration file, issue the following command
sudo nano /etc/dnsmasq.conf
Copy and update the following information at the bottom of the file
Note : You will need to modify it accordingly to reflect your own infrastructure
#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.170,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.160 #-- 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.160 #--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
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 8 – Populate TFTP Folder
Now, we need to populate the TFTP folder structure.
Step 8.1 – Populate bios folder
We have created the folder /tftp/bios in a previous step. This folder will hold the needed pxelinux files that we will be using to boot from network
sudo cp <%your download location%>/bios/com32/elflink/ldlinux/ldlinux.c32 /tftp/bios sudo cp <%your download location%>/bios/com32/libutil/libutil.c32 /tftp/bios sudo cp <%your download location%>/bios/com32/menu/menu.c32 /tftp/bios sudo cp <%your download location%>/bios/com32/menu/vesamenu.c32 /tftp/bios sudo cp <%your download location%>/bios/core/pxelinux.0 /tftp/bios sudo cp <%your download location%>/bios/core/lpxelinux.0 /tftp/bios
Step 8.2 – Populate grub folder
We will do the same for the grub folder. The grub folder contains files that are needed for UEFI computers. We will need to obtain the correct version of grub files (the ones that are signed).
When this is done, we can simply copy the needed file into the tftp boot folder. So, execute the following commands. Change the path accordingly based on your settings…
sudo cp ~/Downloads/grub/usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed /tftp/grubx64.efi sudo cp ~/Downloads/shim/usr/lib/shim/shimx64.efi.signed /tftp/grub/bootx64.efi
Finally, we will copy two additional files from the source iso image. They will server as base for the next step. So, execute the following commands
sudo cp /var/www/html/desktop/u2004/boot/grub/grub.cfg /tftp/grub/ sudo cp /var/www/html/desktop/u2004/boot/grub/font.pf2 /tftp/grub/
Step 8.3 – Populate boot folder
In this step, we need to place the correct bootloader in order for the installation process to start accordingly. We will copy the necessary files from the /var/www/html location. Issue the following commands to copy the necessary files to the correct location
Note : Ensure that the folder /tftp/boot/casper has been created and exists….
sudo cp /var/www/html/desktop/u2404/casper/vmlinuz /tftp/boot/casper sudo cp /var/www/html/desktop/u2404/casper/initrd /tftp/boot/casper
Step 8.4 – Create symbolic link to boot folder
You will also need to create a symbolic link to the /tftp/boot folder. You will need to issue the following command
sudo ln -s /tftp/boot /tftp/bios/boot
Step 9 – Creating/Updating pxelinux.cfg & grub.cfg file
These are the most important files of the configuration. These files tells the target machine where to connect and where the file source files needed to perform the network installation. So, let’s create them…
Step 9.1 – create you pxelinux configuration file
We will also need to create the folder called pxelinux.cfg under the /tftp/bios folder.
sudo mkdir /tftp/bios/pxelinux.cfg
Inside this folder, we will create an empty file called default. This file control the pxelinux behavior. We will populate it with the following code.
DEFAULT menu.c32
MENU TITLE ULTIMATE PXE SERVER - By Griffon - Ver 2.1
PROMPT 0
TIMEOUT 0
MENU COLOR TABMSG 37;40 #ffffffff #00000000
MENU COLOR TITLE 37;40 #ffffffff #00000000
MENU COLOR SEL 7 #ffffffff #00000000
MENU COLOR UNSEL 37;40 #ffffffff #00000000
MENU COLOR BORDER 37;40 #ffffffff #00000000
LABEL Ubuntu Desktop 24.04
kernel /boot/casper/vmlinuz
append nfsroot=192.168.1.160:/var/www/html/desktop/u2404 netboot=nfs ip=dhcp boot=casper initrd=/boot/casper/initrd
Save it
You are ready to move to the next section
Step 9.2 – create you grub configuration file
We are almost done ! Now, we need to create also a grub boot menu and get the proper option available and working. The grub boot loader reads information from the grub.cfg file. If you have followed this step by step guide, the content of the grub.cfg file should look like this
if loadfont /grub/font.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga insmod gfxterm terminal_output gfxterm fi set menu_color_normal=white/black set menu_color_highlight=black/light-gray set timeout=5 menuentry "Ubuntu Desktop 24.04" { set gfxpayload=keep linux /boot/casper/vmlinuz ip=dhcp nfsroot=192.168.1.160:/var/www/html/desktop/u2404/ netboot=nfs ip=dhcp boot=casper initrd /boot/casper/initrd }
Save it
Step 10 – Testing your implementation
At this stage, we have to validate our work. If everything is working as expected, you will be able to boot a BIOS based computer from the network and you would see the following PXE Menu.
Click on Picture for better Resolution
If you start the process from a UEFI based computer, you will see the following menu
Click on Picture for better Resolution
Selecting the menu option, you will see the boot process starting and at the end of the process, you should be see presented with the live version of the Ubuntu 24.04 Desktop Edition. From there you can perform your manual installation.
Click on Picture for better Resolution
Using some “answer file”; it’s possible to automate the installation of your Ubuntu machine. The automation process will not be explained in this post as the post is becoming really long. We will try to provide some instructions in a future post…..
Final Notes
This is it for this post !
Ubuntu 24.04 has introduced a number of changes and we wanted to see if the deployment process through PXE process would be impacted. The installation through PXE is still available with Ubuntu 24.04 Desktop Edition. We had to update slightly the grub.cfg and the pxelinux file but all in all the process seems really similar to what existed previously. This post was focusing on the Desktop Edition. If you follow these instructions, you will be able to perform the installation of Ubuntu 24.04 through the flutter wizard.
The process to deploy Ubuntu 24.04 Server Edition is slightly different and the instructions provided here will not work. We might want to publish a post about how to perform a pxe installation of Ubuntu 24.04 Server Edition in a near future. It might take some time but this is on our roadmap.
Finally, we will probably try to publish also some additional information about how to perform unattended installation for Ubuntu 24.04 (Desktop and Server Edition). Since there are some changes in the installer used by Ubuntu 24.04 (and even previous versions), we want to have a first look at the process. Again, it might not be right away but we hope that we will have time to publish this info.
Till next time
See ya
Hi,
Thanks for your job.
I followed your explanations. All works good excepted one thing.
I can’t the installer to be launched ?!
Regards,
Didier.
@Didier,
Thank you for visiting our blog and providing some feedback… not sure we understand your statement.. So, you can pxe boot but the ubuntu installer is crashing ? or you do not see the installer starting up at all
Till next time
See ya
Hi,
Thanks for your response. I can’t see the installer starting up at all.
Regards,
Didier.
@Didier,
So, to follow up.. Do you see just a black screen after the pxe process or do you see the ubuntu desktop ? have you tried to restart the pxe machine and see if this is better….
We have done some tests… Indeed, we have noticed 1 time of 10 that the target pxe machine goes through the pxe boot process, then it logs into the live installer and we have just a black screen waiting for us. After rebooting, usually, this fix the problem…
Which version of ubuntu are you using 24.04.2 ? UEFI ? Physical machine or virtual machines ?
Hope this help
Till next time
See ya