Skip to content

Conversation

msimerson
Copy link

FreeBSD 13.0+ no longer have boot1.efifat, so replace those instructions with the relevant commands and add reference to loader.efi man page.

FreeBSD 13.0+ no longer have boot1.efifat, so replace those instructions with the relevant commands and add reference to loader.efi man page.
Copy link
Member

@bsdimp bsdimp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@@ -1335,11 +1335,13 @@ For systems using EFI to boot, execute the following command:

[source,shell]
....
# gpart bootcode -p /boot/boot1.efifat -i 1 ada1
# mount_msdosfs /dev/ada1p1 /boot/efi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default this will automatically be mounted (bsdinstall puts it in fstab) and so will fail with mount_msdosfs: /dev/ada1p1: Device busy. If you need to mount it manually for whatever reason, mount -t msdosfs is better than mount_msdosfs (which is a bit of an implementation detail).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction, it "may fail." You're assuming the disks were created with bsdinstall. There are more than a few FreeBSD disks roaming about that were installed with sysinstall or were manually partitioned to match disks installed long ago.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise. I deliberately said by default at the start of the sentence to fully acknowledge there are other ways to get a working FreeBSD system. That is, by default it will fail. That doesn't mean it will always fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

mount -t msdosfs -u /dev/ada1p1 /boot/efi

@@ -1335,11 +1335,13 @@ For systems using EFI to boot, execute the following command:

[source,shell]
....
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes amd64

Copy link
Author

@msimerson msimerson Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.efi

To 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.efi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sergio-carlavilla
Copy link
Contributor

Any news with this patch?
@jrtc27 @msimerson

@msimerson
Copy link
Author

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.

@jrtc27
Copy link
Contributor

jrtc27 commented Jan 19, 2025

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.

@msimerson msimerson closed this Jan 20, 2025
@grahamperrin
Copy link
Contributor

Open bugs reports include:

#408 (comment)

… My interest in improving the docs has been exhausted …

@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 efibootmgr -v in 2023 produced nothing like what's shown under https://www.freebsd.org/releases/14.0R/relnotes/#upgrade.

My own routine includes this, whilst an upgraded but not yet active boot environment is mounted at /tmp/up:

cp /tmp/up/boot/loader.efi /boot/efi/efi/freebsd/loader.efi && cp /tmp/up/boot/loader.efi /boot/efi/efi/boot/bootx64.efi

@msimerson
Copy link
Author

I do a similar thing, but I always add /etc/fstab entries with noauto for every one of the disks that has boot loaders. Eg:

➜ 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	2

I 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

@msimerson msimerson reopened this Mar 20, 2025
more robust instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants