Ubuntu (Focal) PXE Boot with autoinstall
After N
VMs deep in my homelab and delays upon delays (read: procrastination), I’ve finally gotten around to setting up my compute provisioning workflow to do PXE boot and autoinstall. Goodbye install UI, you will not be missed.
Note: I’m running on Proxmox and (virtual) pfSense but that shouldn’t affect much of the setup.
Setup
! Most, if not all, of the commands to be run must be root
TFTP and HTTP Server
- Install the TFTP and HTTP server via:
apt-get -y install tftpd-hpa apache2 |
- Edit
/etc/default/tftpd-hpa
with the following:
# /etc/default/tftpd-hpa |
then
systemctl restart tftpd-hpa |
- Create
/etc/apache2/conf-available/tftp.conf
with:
<Directory /tftp> |
then
a2enconf tftp |
BIOS Boot
- Download the latest .iso and extract the kernel and initrd by:
wget https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso -O /tftp/ubuntu-20.04.3-live-server-amd64.iso |
- Copy over the bootloader to the tftp directory by:
wget http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/pxelinux.0 -O /tftp/pxelinux.0 |
- Install syslinux via:
apt-get -y install syslinux-common |
then
cp /usr/lib/syslinux/modules/bios/{ldlinux.c32,libcom32.c32,libutil.c32,vesamenu.c32} /tftp |
- Create
/tftp/pxelinux.cfg/default
file with:
DEFAULT vesamenu.c32 |
Where:
<SERVER-IP>
- IP of the TFTP server
“autoinstall” Config
- Create
/tftp/cloud-init-bios/user-data
with (password isubuntu
):
#cloud-config |
More options can be found in the reference guide.
- Run
touch /tftp/cloud-init-bios/meta-data
DHCP Update
In my case, I’m running pfSense so I had to update the DHCP server with:
Testing in Proxmox
To test if everything checks out, simply create a VM with no OS media. Network boot is already included in the boot order (last).
Gotchas
Minimum VM memory should be atleast 2GB in order for the installation to succeed.