What options are available to accomplish the following boot scenario?On boot (before boot) contact a defined webserver and ask what to boot (normal answer: boot from local hard drive; alternative answer: boot image XYZ)The goal is to be able to reinstall the clients without the need of a user interaction at the clients. The logical way to do this would be PXE booting but as we don't control the environment defaulting to regular booting PXE is insecure as it would open an attack vector.What I have found and tried so far is the following:Starting Grub2 from local hard drive and chainloading iPXE. iPXE then contacts the defined webserver over http and gets an iPXE script back. But from there I haven't yet found a way to boot from the local drive (except for starting Grub again and ending in an endless loop). The OS I would like to boot is on partition 2 of the same hard drive as Grub/iPXE is started from.Is there an alternative way to accomplish what we try to accomplish?Is there a way to tell Grub to select a different option on the second start (comming back from iPXE) or to tell iPXE to boot from partition 2?Side note: Partition 2 contains a Windows Boatloader and can be booted from the Grub Menu.
How can I ask a defined server what to boot
boot;grub2;boot loader;pxe;netboot
I found a way to accomplish what we were looking for. Thanks go @jc__ for the hint with grubenv and as well as to @Anthon.So here is my solution:Put a iPXE kernel binary (.lkrn) with the custom script to contact the boot control server into /boot Then setup Grub1- to use variable from grubenvGRUB_DEFAULT=saved2- Chain load iPXE on /boot from Grub and include the following command before booting iPXEset saved_entry='<menuentry to boot from local drive>'save_env saved_entry3- Prepend the Grub menuentry which loads the OS from local drive withset saved_entry='<menuentry iPXE>'save_env saved_entry4- If nothing needs to be done the boot control server instructs iPXE to boot from the local drive withsanboot --no-describe --drive 0x805- Grub is loaded again and boots into local drive, setting up next boot to be iPXE again.The boot time into Windows 10 including asking boot control server is about 25 seconds. So actually quite fast. :)