Solved loader.efi, bootx64.efi and stuff

reference:
Code:
FreeBSD local.machine.on.the.desktop 14.0-RELEASE-p2 FreeBSD 14.0-RELEASE-p2 #0: Tue Dec  5 00:31:31 UTC 2023     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
zfs-2.2.0-FreeBSD_g95785196f

I upgraded to 14.0 and then upgraded zfs without event, but I am still a little unsure.

As well as
-rwxr-xr-x 1 root wheel 659968 Nov 16 20:25 /boot/efi/efi/boot/bootx64.efi
(which I copied from /boot/loader.efi), I also have
-rwxr-xr-x 1 root wheel 892928 May 17 2022 /boot/efi/efi/freebsd/loader.efi
which appears to be from the original install.

Why should I have this?

reference: man loader.efi()
Code:
  EFI System Partition
       loader.efi is installed on the ESP (EFI System Partition) in one    of the
       following locations:

       efi/boot/bootXXX.efi    The  default  location  for any EFI loader (see
                   uefi(8) for values to replace `XXX' with).

       efi/freebsd/loader.efi  The  location  reserved    specifically  for  the
                   FreeBSD EFI loader.

Well, which one should I be using? Should I copy /boot/loader.efi to efi/freebsd/loader.efi as well?

Additionally, I have two mirrored disks, nda0 and nda1. nda0 is mounted
/dev/nvd0p1 on /boot/efi (msdosfs, local)

Code:
1. Name: nda0p1
   type: efi
2. Name: nda0p2
3. Name: nda0p3
1. Name: nda0
1. Name: nda1p1
   type: efi
2. Name: nda1p2
3. Name: nda1p3
1. Name: nda1

If I try to mount nda1p1 (I might want to boot from nda1 at some stage), mount -t msdosfs /dev/nda1p1 /mnt, I get
mount_msdosfs: /dev/nda1p1: Invalid argument
So I cannot upgrade bootx64.efi / loader.efi on nda1.
 
What does "mount" show you? Is there an msdosfs line in /etc/fstab? That might give you a hint.

In any case "mount -t msdosfs /dev/gpt/efiboot1 /mnt" will probably do what you want.
 
mount:
Code:
zoroot/ROOT/default on / (zfs, local, noatime, nfsv4acls)
devfs on /dev (devfs)
/dev/nvd0p1 on /boot/efi (msdosfs, local)
zohome on /usr/home (zfs, local, noatime, nfsv4acls)
zoroot on /zoroot (zfs, local, noatime, nfsv4acls)
...

/etc/fstab
Code:
/dev/nvd0p1        /boot/efi    msdosfs    rw        2    2
/dev/nvd0p2        none    swap    sw        0    0
/dev/nvd1p2        none    swap    sw        0    0

mount -t msdosfs /dev/gpt/efiboot1 /mnt:
mount_msdosfs: /dev/gpt/efiboot1: Invalid argument
 
Well, which one should I be using? Should I copy /boot/loader.efi to efi/freebsd/loader.efi as well?
If there's no other OS then yes, just write to both locations.
Which one is actually used depends on your PC - there are a bunch of broken EFI implementations out there which only look at /efi/boot/bootx64.efi and ignore everything else (because that's the variant windows uses).
The correct way would be for every installed os to have its own /efi/<OS-name>/<bootprogram>.efi, but yet again: a lot of EFI implementations are broken.
IIRC the installer tries to detect if there's any other EFI-bootable OS present on the system, and if not it also writes the falisafe variant, otherwise only the second one.


Additionally, I have two mirrored disks, nda0 and nda1. nda0 is mounted
If I try to mount nda1p1 (I might want to boot from nda1 at some stage), mount -t msdosfs /dev/nda1p1 /mnt, I get
mount_msdosfs: /dev/nda1p1: Invalid argument
So I cannot upgrade bootx64.efi / loader.efi on nda1.
The installer had a bug at some time, where it would only create a valid filesystem on the first disk. Just format that partition with newfs_msdos, mount it and copy all contents from the partition on the first disk. Or if you are lazy and the partitions are the same size, just dd the whole partition...
 
I advise you to update both loaders, bootx64.efi and loader.efi. Given that you don't have multiboot on this machine.

efibootmgr -v should tell you what is the loader actually in use.
 
Back
Top