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.
sudo apt install tftpd-hpa isc-dhcp-server syslinux-efi syslinux-common apache2
sudo mkdir /tftpboot
sudo mkdir /tftpboot/pxelinux.cfg
sudo touch /tftpboot/pxelinux.cfg/default
Now we need to open the TFTP configuration file:
sudo vim /etc/default/tftpd-hpa
and make sure it looks like below (TFTP_DIRECTORY
should be the /tftpboot
directory you created before):
and add the following:
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
Also make sure the UDP port 69 is accessible through your local network, then:
sudo systemctl restart tftpd-hpa
Edit the configuration file:
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 8.8.8.8, 8.8.4.4;
# Uncomment this line if you are using your local network
authoritative;
# Configure your subnet
subnet 10.10.30.0 netmask 255.255.255.0 {
range 10.10.30.200 10.10.30.240;
option routers 10.10.30.10;
filename "pxelinux.0";
next-server x.x.x.x;
option bootfile-name "syslinux.efi";
}
Replace the subnet (10.10.30.0
) and range and the gateway (10.10.30.10
) according to your network. Also 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
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
pxelinux.cfg/default
and Copying Required FilesEdit 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.
Also make sure to copy all the following files to the /tftpboot
folder you created before.
sudo cp /usr/lib/syslinux/modules/efi64/{ldlinux.e64,libutil.c32,menu.c32} /tftpboot
sudo cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /tftpboot
Turn on another machine in your local network and try boot up using PXE network.
pxelinux.cfg/default
and Copying Required FilesInstall NFS server by:
sudo apt install -y nfs-kernel-server
Let’s create a folder to share using NFS:
sudo mkdir /srv/nfs/ubuntu1804_src
and let’s edit the configuration file and introduce the the folder we created:
SETTINGS="/srv/nfs *(ro,sync,no_wdelay,insecure_locks,no_root_squash,insecure,no_subtree_check)"
echo $SETTINGS | sudo tee -a /etc/exports
# Reload the settings
sudo exportfs -a
pxelinux.cfg/default
and Copying Required Filessudo apt install -y syslinux pxelinux
sudo cp /usr/lib/PXELINUX/pxelinux.0 /tftpboot
sudo cp /usr/lib/syslinux/modules/bios/{ldlinux.c32,libcom32.c32,libutil.c32,vesamenu.c32} /tftpboot
sudo mkdir -p /tftpboot/pxelinux.cfg
sudo touch /tftpboot/pxelinux.cfg/default
sudo mount -o ro ubuntu-18.04.6-live-server-amd64.iso /mnt
sudo cp -r /mnt/* /srv/nfs/ubuntu1804_src/
sudo cp -r /srv/nfs/ubuntu1804_src/casper/{vmlinuz,initrd} /tftpboot/
Edit the /tftpboot/pxelinux.cfg/default
and add the following configuration:
default vesamenu.c32
label 18040001
menu label ^Install Ubuntu 18.04.6
menu default
kernel vmlinuz
append initrd=initrd boot=casper netboot=nfs nfsroot=x.x.x.x:/srv/nfs/ubuntu1804_src/ nosplash toram ---
Replace the IP address of the NFS server with x.x.x.x
. Now, restart the tftp server and it should work.
sudo systemctl restart tftpd-hpa