doc(ZFS): update UEFI loader instructions for 13+#408
doc(ZFS): update UEFI loader instructions for 13+#408msimerson wants to merge 4 commits intofreebsd:mainfrom
Conversation
FreeBSD 13.0+ no longer have boot1.efifat, so replace those instructions with the relevant commands and add reference to loader.efi man page.
| .... | ||
| # gpart bootcode -p /boot/boot1.efifat -i 1 ada1 | ||
| # mount_msdosfs /dev/ada1p1 /boot/efi | ||
| # cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi |
There was a problem hiding this comment.
Fair point. Most of the other FreeBSD docs I've seen only copy loader.efi to bootx64.efi, as that's correct likely ~99% of the time. The wiki page and man page note there is no 32-bit UEFI support.
The two options 'x64' and 'aa64' would cover probably 99.9% of cases.
# cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
or
# cp /boot/loader.efi /boot/efi/efi/boot/bootaa64.efiTo cover all cases, perhaps borrow from the convention used in the loader.efi man page?
# cp /boot/loader.efi /boot/efi/efi/boot/bootXXX.efi (see uefi(8) for values to replace ‘XXX’ with)I don't have enough knowledge to explain why we don't just direct users to only copy it to the designated FreeBSD spot:
# cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efiThere was a problem hiding this comment.
This needs to follow the same approach as loader.efi(8). Both locations are important, but which is more important depends on your system. Only updating the removable media path would be wrong for most desktop and server systems. Only updating the FreeBSD-specific path would be wrong for most SBC systems.
|
Any news with this patch? |
|
The current instructions are still completely broken for supported versions of FreeBSD. This patch makes them much less broken, but only for the vast majority of FreeBSD users. My interest in improving the docs has been exhausted by perfect standing in the way of better. |
No. The instructions you have provided do not work for the vast majority of FreeBSD users, because they only update the removable media path, which is not what a normal desktop/server installed via bsdinstall will be using. |
|
Open bugs reports include:
@msimerson if it helps you to feel better about the difficulties with documenting things such as this: for a (very) long time, I did things wrong because my brain switched off after My own routine includes this, whilst an upgraded but not yet active boot environment is mounted at
Postscript16.0-CURRENT on ARM64 in QEMUOnly one occurrence of |
|
I do a similar thing, but I always add /etc/fstab entries with ➜ grep efi /etc/fstab
/dev/gpt/nda0-efi /boot/efi msdosfs rw,noauto 2 2
/dev/gpt/nda1-efi /boot/efi msdosfs rw,noauto 2 2I mostly run FreeBSD on servers with mirrored boot disks and those fstab entries are my reminder to update the boot loader on both disks. They also make this little saved snippet work: df /boot/efi | grep /boot/efi && umount /boot/efi
for _fs in $(grep efi /etc/fstab | awk '{ print $1 }'); do
mount -t msdosfs -o longnames $_fs /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/boot*.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi
done |
more robust instructions
|
Cross-reference: Postscript, for anyone who's not already aware: |
| # gpart bootcode -p /boot/boot1.efi -i 1 ada1 | ||
| # umount /boot/efi | ||
| # mount -t msdosfs /dev/ada0p1 /boot/efi | ||
| # cp /boot/loader.efi /boot/efi/efi/boot/boot*.efi |
There was a problem hiding this comment.
The '*' here doesn't make sense.
It should be to bootx64.efi.
With a note somewhere saying that's architecture dependent (but ada is primarily a x86 thing) and please refer to this table for the name of other ports. I think that table is in loader.efi, in the examples.
There was a problem hiding this comment.
My newer devices present at ndaN because they're NVMe. Disks attached via SAS/SCSI (the CAM layer) present as daN. Disks attached via (S)ATA present at adaN. Some RAID controllers present differently. There's no universal command that'll work there, so perhaps it needs to be:
export BOOT_DEVICE="/dev/{daN | ndaN | adaN}" # CUSTOMIZE THIS!
mount -t msdosfs "$BOOT_DEVICE" /boot/efiThe copy command with the * works across TIER 1 (and probably all other) supported architectures:
# ls /boot/efi/efi/boot/boot*.efi
/boot/efi/efi/boot/bootaa64.efi # uname -p = aarch64
/boot/efi/efi/boot/bootx64.efi # uname -p = amd64There was a problem hiding this comment.
If there was a reasonable chance of it getting merged, I'd update this PR with this:
# Common EFI: /dev/nda0 (NVMe), /dev/ada0 (SATA), /dev/da0 (USB/SAS/SCSI)
# Note: For mirrored boot drives, update BOTH disks.
# export EFI_PARTITION="/dev/{ndaN | daN | adaN}" # CUSTOMIZE THIS!
# mount | grep -q /boot/efi && umount /boot/efi
# mount -t msdosfs "$EFI_PARTITION" /boot/efi
# cp /boot/loader.efi /boot/efi/efi/boot/boot*.efi
# cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
# umount /boot/efiThere was a problem hiding this comment.
This is more robust, and compared the more static commands above:
- installs when no boot loader exists
- works with all EFI platforms.
- ARCH matches the two exceptions to the boot{ARCH}.efi naming convention.
- other architectures (arm) work by default
- doesn't require users to figure out partition names
- improves on my in-house script that relied on an up-to-date
/etc/fstab- EFI requires gpart partitions
# discover the EFI name for this systems CPU architecture
export ARCH=$(case "$(uname -p)" in aarch64) echo "aa64" ;; amd64) echo "x64" ;; *) echo "$(uname -p)" ;; esac)
for _efi_part in $(gpart show -p | grep ' efi ' | awk '{ print $3 }')
do
echo; echo " updating $ARCH EFI boot loader in $_efi_part"
mount | grep -q 'on /boot/efi ' && umount /boot/efi
mount -t msdosfs "/dev/$_efi_part" /boot/efi
mkdir -p /boot/efi/efi/boot /boot/efi/efi/freebsd
cp /boot/loader.efi "/boot/efi/efi/boot/boot${ARCH}.efi"
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi
done
Sample Output
amd64 (Intel)
updating x64 EFI boot loader in mmcsd0p1
mount | grep -q /boot/efi && umount /boot/efi
mount -t msdosfs /dev/mmcsd0p1 /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi
updating x64 EFI boot loader in nda0p1
mount | grep -q /boot/efi && umount /boot/efi
mount -t msdosfs /dev/nda0p1 /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi
updating x64 EFI boot loader in nda1p1
mount | grep -q /boot/efi && umount /boot/efi
mount -t msdosfs /dev/nda1p1 /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi
updating x64 EFI boot loader in nda2p1
mount | grep -q /boot/efi && umount /boot/efi
mount -t msdosfs /dev/nda2p1 /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efiARM 64
updating aa64 EFI boot loader in nda0p1
mount | grep -q /boot/efi && umount /boot/efi
mount -t msdosfs /dev/nda0p1 /boot/efi
cp /boot/loader.efi /boot/efi/efi/boot/bootaa64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi
FreeBSD 13.0+ no longer have boot1.efifat, so replace those instructions with the relevant commands and add reference to loader.efi man page.