0

Coming from a legacy boot background, I used to be able to provide server-specific kickstart/boot configs based on the MAC address by creating a /pxelinux.cfg/01-MAC-Address file. I am trying to do something similar with UEFI boot and can't work out how to get a server to use it's specific configuration (i.e. a particular ISO or user-data file as specified in grub.cfg).

I have set up a PXE/TFTP/Apache server, largely following the instructions at this excellent post: https://askubuntu.com/a/1235724/1094816.

It's all working fine, and systems pick up the grub.cfg file as expected. However, when I use a system-specific grub file (e.g., /tfpt/grub/grub.cfg-01-ec-eb-b8-92-44-70) it is ignored. Although this is in the Grub docs, looking at many of the docs where I've seen this, I'm wondering if it's a Fedora-and-derivatives-only option based on the grubx64.efi packaged with them? And if so, what is the method for achieving this with Ubuntu+UEFI?

My current setup:

I am running dnsmasq, tftp and apache2 on Ubuntu 20.04. I am trying to autoinstall an Ubuntu 20.04 server.

Directory structure:

/tftp/
/tftp/grub/grubx64.efi
/tftp/grub/grub.cfg-01-ec-eb-b8-92-44-70
/tftp/grub/grub.cfg
/tftp/initrd
/tftp/pxelinux.0
/tftp/vmlinuz

Contents of /etc/dnsmasq.conf:

interface=enp1s0,lo
bind-interfaces
domain=poseidon.lab
dhcp-range=10.50.129.100,10.50.129.200,255.255.255.0,2h
dhcp-option=3,10.50.129.1
dhcp-option=6,10.50.128.20
server=10.50.128.20
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/tftp
dhcp-mac=set:efi-x86_64,ec:eb:b8:92:44:70
dhcp-boot=tag:efi-x86_64,grub/grubx64.efi

Contents of grub.cfg-01-MAC-ADDRESS:

set default=auto
set timeout=10

menuentry 'Ubuntu 20.04' --id=auto { linux /vmlinuz ip=dhcp url=http://${pxe_default_server}/tftp/ubuntu-20.04-live-server-amd64.iso quiet autoinstall ds=nocloud-net;s=http://${pxe_default_server}/tftp/01-mac-address/ root=/dev/ram0 cloud-config-url=/dev/null initrd /initrd }

1 Answers1

0

Might not be the best answer, but I managed to solve this by doing the following in the default grub.cfg (thanks to Andrew's answer here: https://askubuntu.com/a/1272415/1094816):

set default=auto
set timeout=10

menuentry 'Ubuntu 20.04 - autoinstall' --id=auto { linux /vmlinuz ip=dhcp url=http://${pxe_default_server}/tftp/ubuntu-20.04-live-server-amd64.iso quiet autoinstall ds=nocloud-net;s=http://${pxe_default_server}/tftp/01-${net_default_mac}/ root=/dev/ram0 cloud-config-url=/dev/null initrd /initrd }

And maintaining a meta-data and user-data file for each server in a separate directory for each host:

/tftp/
/tftp/01-aa:bb:cc:dd:ee:00/meta-data
/tftp/01-aa:bb:cc:dd:ee:00/user-data

So when server with MAC aa:bb:cc:dd:ee:00 boots, it will download those files to configure the server. Seems to work so far.