Ask Ubuntu Asked by Dennis van Dok on February 4, 2021
In the past I’ve managed the installation of dozens of Ubuntu 18.04 servers with PXE boot and pxelinux. This worked well, as each system had its own file named after the mac address of the interface that would talk DHCP/PXE. These files would then point to their respective preseed URLs to get the installation going.
Our newer machines only do EFI booting. There is a http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/uefi/grub2-amd64/current/grubnetx64.efi that can perform the same role, except it doesn’t look up the individual machine’s files anymore; it just calls for a common grub.cfg.
I’ve looked at the CentOS7 grub-x86_64.efi which does follow the old method of MAC address based lookups, but unfortunately this version is unable to boot Ubuntu install kernels (basically it hangs after loading the kernel and initrd).
How do I set it up so I can install all my machines automatically?
If you really want to do individual config file based on mac address, you can make the contents of your grub.cfg
something like
if [ -s ${prefix}/${net_default_mac} ]; then
source ${prefix}/${net_default_mac}
fi
Personally, I find grub much more flexible than pxelinux because the grub config can use variables and logic branches. I tend to keep a generic grub.cfg
that uses variables that can be set based on the machine attributes.
Here is a small example
set my_interface="auto"
if [ "x${net_default_mac}" = "x01:23:45:67:89:ab" ]; then
echo "using variables for template"
set my_label="template"
set my_preseed=tftp://${pxe_default_server}/preseed/preseed.cfg
fi
if [ -n "${my_preseed}" ]; then
menuentry "Xenial Install - automated - ${my_label}" --id=install_xenial_unattended {
set gfxpayload=keep
echo "ANY EXISTING INSTALL WILL NOW BE OVERWRITTEN"
echo "THERE WILL BE NO PROMPTS"
echo "LAST CHANCE TO ABORT (poweroff to abort, wait or hit esc to continue)"
sleep 10 --verbose --interruptible
echo "Loading Kernel..."
linux /ubuntu/xenial/amd64/ubuntu-installer/amd64/linux netcfg/choose_interface=${my_interface} auto=true priority=critical url=${my_preseed} ${my_kernel_install_args} DEBCONF_DEBUG=5 ---
echo "Loading Ram Disk..."
initrd /ubuntu/xenial/amd64/ubuntu-installer/amd64/initrd.gz
}
fi
You can also combine these techniques so that you can put variable assignments into a file named for the mac address so they get loaded dynamically.
Answered by Andrew Lowther on February 4, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP