We have a system where an SBC will use TFTP to pull down a boot-loader configuration.
- If the SBC is a UEFI system, it will pull down a GRUB2 configuration.
- If the SBC is a BIOS system, it will pull down a PXELINUX configuration.
Then the SBC will use the boot-loader configuration to PXE boot into an operating system whose image is served over NFS. With either type of boot-loader, the configuration must read a file on the hard disk to determine some kernel command line parameter.
This is straightforward on the GRUB2 configuration. Here is what example code looks like for this configuration:
set timeout=0
set default=0
if [ -e (hd0,1)/some_predetermined_file ]; then
echo 'Found indicator file.'
set default=1
fi
menuentry 'CentOS 7 Option 0' {
linuxefi /images/vmlinuz $cmdline
initrdefi /images/initrd.img
}
menuentry 'CentOS 7 Option 1' {
linuxefi /images/vmlinuz $cmdline other_parameter
initrdefi /images/initrd.img
}
My question is, is it possible to have conditional logic like this in a PXELINUX configuration? Proposed is something like:
default centos-0
display help.txt
[ -e (hd0,1)/some_predetermined_file ] && default centos-1
label centos-0
kernel vmlinuz
append initrd=initrd.img $cmdline
label centos-1
kernel vmlinuz
append initrd=initrd.img $cmdline other_parameter
I have read through the configuration file specification at https://wiki.syslinux.org/wiki/index.php?title=PXELINUX but nothing jumps out at me as the right way forward. Maybe general scripting and/or disk access in the PXELINUX environment is impossible, or it is so obvious it goes without saying. Many thanks.