Stop EFI boot order being mangled

This is not strictly a server-specific topic but this is something that probably becomes more of a problem with server and automated provisioning environments. Though in my case it's my home lab.

Most of my home lab gear is fairly old (6-10 years), some of which has very early UEFI implementations so I left all of it booting in legacy/BIOS boot mode to avoid the hassle. Now I'm starting to replace it with newer old gear (bargains/refurbs etc) which support UEFI so I may as well switch over where I can.
I have a home-made iPXE network boot and provisioning infrastructure - basically an iPXE menu with presets that I can either choose interactively or set on the boot server by making an entry in a YAML file for the MAC address and the iPXE menu option with any additonal command line flags. I often install stuff, blow them away, or boot from iSCSI (and less-so these days Fiber Channel) volumes. Network booting into iPXE gives me the flexibility to manage booting in a completely head-less environment and lets me store everything in version control and it has always worked really well... until UEFI has come along.

The problem I have is that whenever I insert a bootable USB, an old disk with an installation on, install a new OS on disk etc, the UEFI boot order which was always configured to PXE from the onboard NICs gets overridden by whatever has just been inserted/installed.
It's incredibly annoying not having a static boot order.
Even if PXE fails then it would always just pick the next available device anyway but I just cannot get PXE to remain as the first option in any of the BIOS screens of the newer machines I've been playing with (old refurb ex-office desktop PCs and an older SuperMicro X11 board etc).

Has anyone else experienced this and has any thoughts/solutions?
If I was consistently booting into Linux every time then I would just set boot order back to PXE using efibootmgr. If I was using server-grade kit with IPMI then running `ipmitool chassis bootdev` on a loop across the management network would probably be needed - yuck.

I don't suppose there are any standard mechanisms in UEFI to set an absolutely fixed boot order to attempt PXE boot first under any circumstances?

More generally though having a user-facing operating system being able override the BIOS boot order, and no ability to enforce/override this on the BIOS/UEFI side, seems completely mad.

Cheers, B
 

dbwillis

Ars Tribunus Militum
2,662
I have the same headache with Symantec Altiris and new(er) HP Desktops like the G4/G5 models of the Desktop Mini (havent tested the G6 yet)

out of the box, change BIOS order to Network/SSD (leaving UEFI unchanged), then build the machine, afterwards the 'Windows Boot Manger' gets put 1st.
Really sucks when you need to rebuild a PC in a remote site. I dont have the same issue with the HP Desktop Mini 800 G2/G3 (never tried Win10 on G1 Mini's)

I actually tried several ways to get it to boot to the network using the Advanced Startup section of Win10...no luck though
 
  • Like
Reactions: Danger Mouse

Paladin

Ars Legatus Legionis
33,855
Subscriptor
Every server I have worked with in memory (mostly Dell but a couple others like Cisco UCS and some Supermicro etc) and the business class desktops (Optiplex mostly) have not had that issue. Once you set a boot order, it remains in place *unless* you remove the existing top boot option media. If you have it set to boot from C: for windows, and you pull the hard drive, it's seemingly up to the hardware brand's developers whether it will then default to the next option as the new top option (if there is a second option in the list) or it might reset to some factory default or just nothing, boot failed and wait for admin help.

I've never had a machine have a problem when set to PXE as first option later change itself (without a factory reset or something), maybe on a BIOS update but even that I can't remember ever specifically happening.

In my experience, once you set a viable boot option, it stays there unless you do something to break it.
 
It feels like the OS is bumping itself to the top of the order, Linux I imagine just using efibootmgr. ESXi installs do the same.

Huh, interesting. So is there something in the UEFI implementations of server-grade or business-class hardware described that blocks efibootmgr or equivalent OS-level tooling from overwriting the boot order EFI variable(s)?
 
  • Like
Reactions: Danger Mouse
In my experience it's universal (on client end hardware, nor sure about servers) that Windows Boot manager puts itself at the start of the queue. I find it a handy feature to tell you the truth. But I can see how if you don't want that, it's a PITA.
But Dell, Lenovo & HP laptops all do it. I've not paid attention to the small dell servers I've used.

And I've never looked for a way to disable it (Nor seen it by accident on the way through the UEFI setup).
 
  • Like
Reactions: Danger Mouse
Have you tried to set a BIOS password, reboot and then set your boot order? It should make the boot order immutable with the possible exception if you still have "Fast Boot" or similar enabled. That may still default to the EFI boot partition if it's on.

This definitely isn't correct with the Devices I've used. I ALWAYS set a BIOS password (Because I have users that are potentially evil). You can delete the Windows Boot manager entry, set it to netboot first and after the first WDS pass, the Windows Boot Manager entry is back at the top.
 

Danger Mouse

Ars Legatus Legionis
39,080
Subscriptor
I have the same headache with Symantec Altiris and new(er) HP Desktops like the G4/G5 models of the Desktop Mini (havent tested the G6 yet)

out of the box, change BIOS order to Network/SSD (leaving UEFI unchanged), then build the machine, afterwards the 'Windows Boot Manger' gets put 1st.
Really sucks when you need to rebuild a PC in a remote site. I dont have the same issue with the HP Desktop Mini 800 G2/G3 (never tried Win10 on G1 Mini's)

I actually tried several ways to get it to boot to the network using the Advanced Startup section of Win10...no luck though

Are you using 64bit or 32bit WinPE builds?

Newer NIC drivers are 64bit only and so only 64bit WinPE will work for newer NICs from Intel.
 

dbwillis

Ars Tribunus Militum
2,662
Our PE Images are 64bit PE10, weve no problem booting any of our machines into PXE.
The issue is with full UEFI on the HP Mini Desktop 800 G4/G5 models is the Windows Boot loader gets put at the top of the list after the OS is put down.
Our process is : unbox machine, scan asset tag on the box (into Excel) and peel n stick it to the PC, scan MAC address from the box (into Excel), set boot order NIC>SSD, power down.
Then we go to our home built web page for builds, pick the Symantec server we are going to use, input the MAC, input the asset, then pick the build options (location, dept, domain, software template, any additional apps or additional admin accounts), save the job.
Next time that PC boots up, hits the PXE process....finds there is a job for that MAC, proceeds to build the PC, when done it emails the submitter.
HP Mini 800 G2/G3 keep the boot order NIC>HDD, even after a bios update, but those arent full UEFI I think.
The G4/G5 models change the boot order to put the windows boot loader top/before the NIC, so lets say I need to rebuild 140 machines, in place, at a remote site from W10 1809 to W10 LTSC, if they are G2/G3, once I reboot them, those are good, G4/G5 wont get the PXE info as thats after the SSD, so they dont build, someone manually has to go to the machine and F12 to pick network boot. I tried using the advanced startup of Win10 to see if I could get it to boot from network, but it only showed some USB and other options, nothing for network.

I did find one person with some PS info that could work, but I havent tried it >> https://serverfault.com/questions/71433 ... om-windows
 
Random thought ... what if you delete the (or edit) the disk boot entry, so that the UEFI doesn't see a valid windows boot manager, and then it will fall back to the next boot item, which should be netboot. It doesn't matter if you stuff Windows up at this time, you're about to blow it away anyway.

bcdedit /delete looks like it will do what you want (I think).
 
This whole thing is astonishing.
I guess it's in the UEFI spec and fundamental mechanisms that Operating Systems have permission to override the system's boot order - utterly brainless IMO.
The only way to select an alternate boot device requires interactive access, either updating the boot order in BIOS or triggering a boot override menu.
I don't at all want to to create tooling for each/any OS to be able to undo what the OS has literally just decided to do to the boot order. Or in an enterprise environment with IPMI/out-of-band is the expectation that you will be repeatedly running `ipmitool chassis bootdev pxe` on a tight loop across all hosts in a management network? Madness.

I would guess the concept is to avoid spending 1-5s polling boot devices unnecessarily in laptops/desktops. For servers it's less critical as you'll probably then spend the next 20 minutes enumerating memory, loading $VENDOR Intel Lifecycle Management System Garbage Engine etc.

Anyway I've been trying a few things this weekend with an MSI B450M motherboard. The section in the BIOS is even titled `FIXED BOOT PRIORITIES`... which gets blasted away regardless of what OS I install: Linux, Windows, ESXi.
The MSI motherboard BIOS screen suggests that you are almost setting device "classes" in priority order, which would at least be something if that remained fixed instead of the actual device.
One thing I thought that might work was putting my _light_ iPXE EFI binary (which then loads my iPXE menu over HTTP) on a FAT32 USB key and set `USB Keys` as the top boot priority instead of Net devices. Since if ever you wanted to override boot in an emergency or one-off basis then inserting a USB key and having the system automatically prioritise it might be considered useful. However, again, after installing ESXi or Linux then `UEFI Hard Disk` has overwritten `UEFI USB Keys` as the top priority.

This is honestly such an unbelievable oversight by UEFI implementations and BIOS vendors in my opinion. Why has everyone put up with this for so many years? It's not an improvement.

EDIT: It's even worse actually. I am finding that after a Linux kernel update or upgrading the ESXi image on the host, the boot order again gets mangled. If it meant manually setting it _again_ in the BIOS only after initial provisioning then that would at least be something, but to have it mangled after each OS update is 🤮
 

Danger Mouse

Ars Legatus Legionis
39,080
Subscriptor
Our PE Images are 64bit PE10, weve no problem booting any of our machines into PXE.
The issue is with full UEFI on the HP Mini Desktop 800 G4/G5 models is the Windows Boot loader gets put at the top of the list after the OS is put down.
Our process is : unbox machine, scan asset tag on the box (into Excel) and peel n stick it to the PC, scan MAC address from the box (into Excel), set boot order NIC>SSD, power down.
Then we go to our home built web page for builds, pick the Symantec server we are going to use, input the MAC, input the asset, then pick the build options (location, dept, domain, software template, any additional apps or additional admin accounts), save the job.
Next time that PC boots up, hits the PXE process....finds there is a job for that MAC, proceeds to build the PC, when done it emails the submitter.
HP Mini 800 G2/G3 keep the boot order NIC>HDD, even after a bios update, but those arent full UEFI I think.
The G4/G5 models change the boot order to put the windows boot loader top/before the NIC, so lets say I need to rebuild 140 machines, in place, at a remote site from W10 1809 to W10 LTSC, if they are G2/G3, once I reboot them, those are good, G4/G5 wont get the PXE info as thats after the SSD, so they dont build, someone manually has to go to the machine and F12 to pick network boot. I tried using the advanced startup of Win10 to see if I could get it to boot from network, but it only showed some USB and other options, nothing for network.

I did find one person with some PS info that could work, but I havent tried it >> https://serverfault.com/questions/71433 ... om-windows

Thanks for the detail. That’s really helpful.