UEFI booting survey
markmi at dsl-only.net
Tue Dec 19 23:26:48 UTC 2017
On 2017-Dec-19, at 1:49 PM, Warner Losh <imp at bsdimp.com> wrote:
> On Dec 19, 2017 10:58 AM, "Mark Millard" <markmi at dsl-only.net> wrote:
>> On 2017-Dec-18, at 2:37 PM, Warner Losh <imp at bsdimp.com> wrote:
>> > . . .
>> > Or the following pseudo-code with all the weird special cases removed for clarity
>> > load loader.efi from ESP
>> > if BootXXXX uefi variable holds a second path, use that for root/kernel
>> > otherwise if an override variable holds a kernel/root path, use that
>> > otherwise scan for a usable ZFS pool, use that if it exists
>> > otherwise use the same partition loader.efi was booted from for root/kernel if it's usable
>> > otherwise use the first UFS partition on the ESP that's usable.
>> > A partition is usable if /boot/loader.rc exists on that path.
>> What will be the role of /etc/fstab in establishing
>> were the kernel is loaded from? Where world is
>> loaded from? Where/how does use of /etc/fstab for
>> specifying the root file system mount fit in the
>> above pseudo-code?
> Same as today: it is what the boot loader passes to the kernel as the Unix name of /. I have no plans to change that. It's of almost no use to the boot loader, since it can't know what BIOS device da3 is, for example, if that's in fstab. Or even more complex examples like /dev/mirror/primary. Efibootmgr can take Unix devices and paths and turn them into UEFI paths so we know what devices to use for what. In the absence of those, or an equivalent fallback, we are quite limited in what we can do since we don't have the context needed to translate.
It sounds different then the results I get with ubldr.bin
on a rpi2 V1.1 . With the usdcard having a UFS / with
/etc/fstab (redirecting to a USB SSD stick)
/boot/* (with /boot/kernel/ empty and /boot/dtb/ empty)
the result is that all 3 of the following come from the
USB SSD stick based on the "/" line from the /etc/fstab
from the usdcard:
/ (mounted root file system)
In other words: it appears that for ubldr.bin on
a rpi2 V1.1 /etc/fstab is read and used before
finding the kernel that is to be loaded. (It or
another /etc/fstab may be read again later.)
/usr/src/stand/common/boot.c does show an explicit
attempt to find a /etc/fstab:
# grep -r /etc/fstab /usr/src/stand/
. . .
/usr/src/stand/common/boot.c: * Try to find the /etc/fstab file on the filesystem (rootdev),
/usr/src/stand/common/boot.c: sprintf(lbuf, "%s/etc/fstab", rootdev);
. . .
That is from getrootmount(char *rootdev):
char lbuf, *cp, *ep, *dev, *fstyp, *options;
int fd, error;
if (getenv("vfs.root.mountfrom") != NULL)
error = 1;
sprintf(lbuf, "%s/etc/fstab", rootdev);
if ((fd = open(lbuf, O_RDONLY)) < 0)
. . .
Supporting detail for the example rpi2
With /mnt being the / from the usdcard:
# find /mnt -print | more
# more /mnt/etc/fstab
/dev/da0p1 / ufs rw,noatime 1 1
/dev/da0p2 none swap sw 0 0
May be this is somehow special to the rpi2 or to
ubldr.bin operation. (I've never managed to identify
accidents from deliberately working status in this
>> (For my particular interest the context uses UFS, not
>> > What is being deleted is one final step: "otherwise use the first UFS partition on any drive in a random order that's usable." which used to be at the end of the boot1.efi psuedo code. It's my belief that no such installations actually use this due to the random factor today (plug in a new USB drive and it might take over). If my belief is wrong, it's my belief that efibootmgr will solve it, and failing that, the fallback mechanism (for platforms that use u-boot + EFI where UEFI variables don't work) will allow the two or three people that are doing this today.
markmi at dsl-only.net
More information about the freebsd-current