Skip to content

Instantly share code, notes, and snippets.

@Rafisto
Created May 13, 2024 19:20
Show Gist options
  • Save Rafisto/7bb0a0fe6ef0ed85e1cb062cc7038f83 to your computer and use it in GitHub Desktop.
Save Rafisto/7bb0a0fe6ef0ed85e1cb062cc7038f83 to your computer and use it in GitHub Desktop.
pxe-boot

How to easily setup PXE boot for cluster provisioning

This guide will show you how to setup a PXE boot server to provision a cluster of machines. For the sake of this guide, we will be using system agnostic docker containers to simulate the DHCP and the PXE boot server.

Featured technologies:

PXE boot description

Generally speaking, PXE boot is a way to boot a machine over the network. This is useful when you have a large number of machines to provision and you don't want to manually install the OS on each machine. The PXE boot server will provide the necessary files to boot the machine and install the OS.

Steps:

  1. The machine boots up and sends a DHCP request.
  2. The DHCP server responds with the IP address of the PXE boot server and next_file - the file to boot from.
  3. The machine downloads the necessary files from the PXE boot server.
  4. The machine boots from the downloaded files and installs the OS.
  5. The machine reboots and boots from the local disk.
  6. The machine is provisioned.

Setup

Netbootxyz will provide the necessary files to boot the machine and the DHCP server will provide the IP address of the PXE boot server and the next_file to boot from.

Use the first part of the docker-compose file to setup the PXE boot server:

version: '3.7'
services:
  netbootxyz:
    image: lscr.io/linuxserver/netbootxyz:latest
    container_name: netbootxyz
    network_mode: "host"
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Warsaw
      - MENU_VERSION=2.0.78
      - PORT_RANGE=30000:30010
      - SUBFOLDER=/
    volumes:
      - ./config:/config
      - ./assets:/assets
    ports:
      - 3000:3000
      - 69:69/udp
      - 8080:80
    restart: unless-stopped

Use the second part of the docker-compose file to setup the DHCP server:

version: '3.7'
services:
  dhcp-server:
    image: networkboot/dhcpd
    container_name: dhcp-server
    network_mode: "host"
    restart: always
    volumes:
      - ./data/:/data/
    ports:
      - "67:67/udp"
      - "67:67/tcp"
    privileged: true
    cap_add:
      - NET_ADMIN

Remember to create the necessary /data/dhcpd.conf file with the following content:

subnet 192.168.100.0 netmask 255.255.255.0 {
    range 192.168.100.100 192.168.100.200;
    option routers 192.168.100.1;
    option domain-name-servers 192.168.100.1;
    next-server 192.168.100.184;
    filename "netboot.xyz-undionly.kpxe";
}

Where:

  • subnet - the subnet of the network. Make sure it matches your network configuration.
  • range - the range of IP addresses to assign to the machines.
  • option routers - the IP address of the router.
  • option domain-name-servers - the IP address of the DNS server.
  • next-server - the IP address of the PXE boot server.
  • filename - the file to boot from. This file is provided by the PXE boot server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment