Skip to content

PXE Boot

Overview

  • Ansible renders the PXE artifacts (grub config and per-host preseed)
  • OPNsense provides DHCP/TFTP for the bootloader and grub.cfg
  • TrueNAS hosts the larger files (kernel/initrd and preseed files) over HTTP or NFS

Prerequisites

Host / Management machine running config via Ansible

  • ansible
  • python-netaddr

OPNsense

OPNsense tftp/netboot will provide the grub efi boot file and config to hand off to a fileserver

  • os-tftp package installed

  • DHCP service on appropriate subnet [Services > DHCPv4 > <INTERFACE>] is configured for network boot. At minimum:

txt Set next-server IP: 192.168.1.1 # the TFTP server, aka our OPNsense device's IP Set default bios filename: grubx64.efi # or pxelinux.0 for legacy bios

Fileserver

tftp is a poor way to transfer large files. A local web- or NFS- server is a much better solution to deliver netboot and preseed assets to the pxe machine. Thus, we will use TrueNAS with webdav http server.

Recommended layout:

  • OPNsense TFTP root: grubnetx64.efi.signed and grub.cfg
  • TrueNAS webdav HTTP root: linux, initrd.gz, and preseed/<hostname>.cfg
  • grub.cfg points preseed/url= at the TrueNAS HTTP URL

Nodes

  • Configure BIOS:
  • disable c-states
  • enable PCIe wake
  • enable wake-on-lan
  • enable boot from network
  • set boot priority for network
  • disable CSM/legacy boot

To re/install OS from PXE, the NIC must have boot priority, otherwise the node will boot from disk Once the OS is PXE-installed, can set priority to local drive

Create PXE server

  1. Configure inventory

  2. Render PXE artifacts from the repo root:

sh # # install ansible packages # ansible-galaxy collection install -r requirements.yaml # render netboot kernel/initrd, grub.cfg, and per-host preseeds ansible-playbook -i ./ansible/inventory/hosts.yaml ./ansible/playbooks/pxe.yaml --tags "render" --ask-become-pass

  1. Publish artifacts to TrueNAS:

sh ansible-playbook -i ./ansible/inventory/hosts.yaml ./ansible/playbooks/pxe.yaml --tags "push"

  1. Configure OPNsense DHCP/TFTP:

  2. Ensure DHCP is set to hand out next-server and grubx64.efi

  3. Ensure TFTP root contains grubnetx64.efi.signed and grub.cfg

  4. Boot a node and select the per-host entry:

  5. PXE boot the node

  6. In GRUB, choose Debian (auto by host) and select the hostname

References

grub.cfg

Alternatives

Ubuntu/Canonical MAAS and MaaS at home Sidero Rackn Digital Rebar Provider and edgelab tinkerbell