Install Ubuntu 20.04 via PXE UEFI Setup

January 03, 2021

By following this tutorial, you will boot up Ubuntu 20.04 via an image hosted in another machine in your local network. For this purpose, you need to install and configure a DHCP, TFTP and Apache servers. In this tutorial, we will install all services on one machine.

Getting Started

Installing Packages

sudo apt install tftpd-hpa isc-dhcp-server syslinux-efi syslinux-common apache2

Configuring TFTP server and Copying Required Files

sudo mkdir /tftpboot

sudo cp /usr/lib/syslinux/modules/efi64/{ldlinux.e64,libutil.c32,menu.c32} /tftpboot
sudo cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /tftpboot 

sudo mkdir /tftpboot/pxelinux.cfg
sudo touch /tftpboot/pxelinux.cfg/default
sudo vim /etc/default/tftpd-hpa

Now make sure TFTP configuration file looks like below (TFTP_DIRECTORY should be the /tftpboot directory you created before):

# /etc/default/tftpd-hpa


Also make sure the UDP port 69 is accessible through your local network, then:

sudo systemctl restart tftpd-hpa

Configuring DHCP Server

sudo vim /etc/dhcp/dhcpd.conf 

Specify the subnet for the allocation of initial IPs to the machines:

# Specify the nameservers
option domain-name-servers,;

# Uncomment this line if you are using your local network

# Configure your subnet
subnet netmask {
    option routers;
    filename "pxelinux.0";
    next-server x.x.x.x;
    option bootfile-name "syslinux.efi";

Replace the IP address of the TFTP server with x.x.x.x. Since we will bring up all these servers in one machine, this should be the IP address of the current machine.

Now find your MAC address of the interface that the DHCP server should listen to (instead of eno2, use your interface name):

ifconfig eno2 | grep ether

Open the file below and enter the MAC address in INTERFACESv4 field.

sudo vim /etc/default/isc-dhcp-server

And finally:

sudo systemctl restart isc-dhcp-server

Configuring Apache Server

Download the latest version of Ubuntu 20.04 and then:

mount -o ro ubuntu-20.04-live-server-amd64.iso /mnt
cp /mnt/casper/initrd /tftpboot
cp /mnt/casper/vmlinuz /tftpboot

sudo mkdir -p /var/www/html/ubuntu2004
cp ubuntu-20.04-live-server-amd64.iso /var/www/html/ubuntu2004

Now edit the file /tftpboot/pxelinux.cfg/default as below to point to the address of the Ubuntu ISO:

sudo vim /tftpboot/pxelinux.cfg/default
DEFAULT install
 LABEL install
 KERNEL vmlinuz
 INITRD initrd
 APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=http://<IP-ADDR>/ubuntu2004/ubuntu-20.04.1-live-server-amd64.iso

Instead of IP-ADDR simply provide the IP address of the current machine, generally this should be address of the Apache server which hosts the Ubuntu ISO.


Turn on another machine in your local network and try boot up using PXE network.

Ubuntu Networking Linux