An idea for the EFI (LUA) loader....
Date: Tue, 17 Jun 2025 01:05:13 UTC
Here's the scenario: /You have an embedded system that boots EFI. You can't control other than the media that's in the box that it boots from (which someone sticks in there.) There might be other media in there, and there might not./ Right now the FreeBSD EFI loader will boot from the first bootable "thing" it finds unless told otherwise (e.g. "rootdev=") The problem is that it wants something like "rootdev=disk0s1a" -- a full specification. But what happens if someone sticks another device in there /and the EFI BIOS enumerates it first?/ Its not bootable (doesn't have an EFI partition) so the BIOS doesn't try to boot it, but it /does /enumerate it so now the disk is "disk1s1a" -- and if you set disk0 you are now stuck at the loader prompt. Which is ok if there's a console you can key in where to boot from and then fix loader.conf. If the machine is headless..... If loader.efi could take a syntax /without /the disk (e.g. "s1a") and, if that was what was specified /it would look on the device loader.efi was loaded from /then it wouldn't matter if someone did this. Once the kernel is loaded it should be ok. You'd think you could detect this with either efibootmgr (what order will it enumerate in?) or from sysctl to figure out where it booted from, but nope -- what's in there may not match how the BIOS enumerated it, never mind that someone could unplug a USB device (or pull an nVME stick) and change it. I've got a machine here that demonstrates this; it SAYS it loaded off disk0 but the BIOS says the boot device is disk1 and if I put disk0.... in loader.conf it tries to boot the nVME device instead of the USB stick. A minimal way would be to be able to discern what the BIOS saw as the enumerated device it loaded from, but even better, I think, would be to be able to specify just the partition and slice/filesystem and have the drive default to "where loader.efi came from" which, I suspect, would resolve both possibilities. Obviously if the BIOS enumerates something that has a valid EFI partition it can still get it wrong but if not that should work -- yes? Am I nuts? :-) PS: I've got zero experience with lua as a language so if I start digging into this the learning curve might be pretty steep where for someone who's coded in lua it might be five minutes..... unless I'm wildly off-base here. -- Karl Denninger karl@denninger.net /The Market Ticker/ /[S/MIME encrypted email preferred]/