Set Up per Host PXE Configuration Files

This guide will walk you through setting up PXE configuration files for each of your physical hosts that will bootstrap the OS installation. You will make use of the kernel and initramfs and the OS configuration file for your desired OS.

Note

You will configure dnsmasq on your bootstrap host to serve the PXE configuration files for each physical host. If your TFTP server lives outside of your bootstrap host, configure it accordingly.

What You’ll Need

For each physical host, you have to provide

  • the MAC address, and
  • the hostname.

Procedure

Important

Repeat the following steps for each physical host.

  1. Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:

    root@host:~# apt-get install -y j2cli
  2. Specify any host-specific information.

    1. Specify the hostname of the physical host:

      root@host:~# export HOSTNAME=<HOSTNAME>

      Replace <HOSTNAME> with the hostname of your physical host. For example:

      root@host:~# export HOSTNAME=node1
    2. Specify the MAC address of the physical host:

      root@host:~# export MAC=<MAC>

      Replace <MAC> with the MAC address of your physical host. For example:

      root@host:~# export MAC=aa:8c:dc:40:33:e1
    3. Specify the address of your webserver:

      root@host:~# export WEBSERVER_ADDRESS=<ADDRESS>

      Replace <ADDRESS> with your webserver address. For example:

      root@host:~# export WEBSERVER_ADDRESS=192.168.2.10

      Note

      This should be the address of your bootstrap host.

  3. Create the PXE configuration file. Choose one of the following options based on your desired OS.

    1. Set the path of the PXE configuration file. This is derived from the MAC address of the physical host. For example, for MAC address aa:8c:dc:40:33:e1 the PXE configuration file should go under /var/lib/tftpboot/pxelinux.cfg/01-aa-8c-dc-40-33-e1:

      root@host:~# export PXE=/var/lib/tftpboot/pxelinux.cfg/01-${MAC//:/-}
    2. Copy and paste the following code inside pxe.j2:

      pxe.j2
      1default install
      2prompt 1
      3timeout 500
      4-4
      4label install
      5 menu label Install Rocky Linux 8
      6 kernel /Rocky8/vmlinuz
      7 append initrd=/Rocky8/initrd.img inst.repo=http://{{ WEBSERVER_ADDRESS }}/iso/Rocky8 inst.ks=http://{{ WEBSERVER_ADDRESS }}/conf/{{ HOSTNAME }}.cfg net.ifnames=0 ip=dhcp

      Alternatively, download the file above and upload it to your bootstrap host.

    3. Render the PXE configuration file:

      root@host:~# j2 pxe.j2 -o ${PXE?}

    Note

    This example configuration will:

    • Obtain kernel and initramfs from your TFTP server.
    • Use the Kickstart configuration file from your HTTP server.
    • Use predictable network interfaces names.
    • Use DHCP to configure the network interface.

Verify

  1. Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:

    root@host:~# apt-get update root@host:~# apt-get install -y tftp-hpa
  2. Verify that you can download the PXE configration file for your physical host:

    root@host:~# tftp -v <IP> -c get /pxelinux.cfg/01-aa-8c-dc-40-33-e1 /dev/null Connected to <IP>, port 69 getting from <IP>:/pxelinux.cfg/01-aa-8c-dc-40-33-e1 to /dev/null [netascii] Received 617 bytes in 0.0 seconds [571972 bit/s]

    Replace <IP> with the IP address of your bootstrap host, for example:

    root@host:~# tftp -v 192.168.2.10 -c get /pxelinux.cfg/01-aa-8c-dc-40-33-e1 /dev/null Connected to 192.168.2.10 (192.168.2.10), port 69 getting from 192.168.2.10:/pxelinux.cfg/01-aa-8c-dc-40-33-e1 to /dev/null [netascii] Received 617 bytes in 0.0 seconds [571972 bit/s]

Summary

You have successfully created PXE configuration files for your physical hosts.

What’s Next

The next step is to install your desired OS on your physical hosts using your PXE Boot environment.