Bug 295289 - Framework 12 laptop incorrectly boots NVMe when you try to boot USB memstick
Summary: Framework 12 laptop incorrectly boots NVMe when you try to boot USB memstick
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: Unspecified
Hardware: amd64 Any
: --- Affects Many People
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-05-14 18:46 UTC by Devin Teske
Modified: 2026-06-29 18:00 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Teske freebsd_committer freebsd_triage 2026-05-14 18:46:14 UTC
Take any release/snapshot of USB memstick installer -- from 14.4-RELEASE to 16.0-CURRENT (20260512 snapshot) -- and write it to any USB storage device (regardless of USB-A or USB-C) and insert it into any USB port on a Framework 12 laptop and try to boot the thing by any means.

If the internal NVMe is blank (read: no EFI boot partition with /EFI/BOOT/bootx64.efi file), then congratulations, your attempt to boot from the memstick will succeed and you can installl FreeBSD.

ASIDE: if you opt to keep secure boot enabled, you simply have to boot while spamming F2 to get to the Secure Boot Administration menu where you can enroll the memstick into the trusted devices database. It doses not matter if secure boot is enabled after install however, the bug remains with zero recourse other than the two stated exceptions below.

If you physically pull or wipe the NVMe drive, you can once again boot the memstick (in the event, for example, you need to again access any FreeBSD installer memstick for any reason).

Alternatively, if you can drop the EFI loader (booting off the NVMe) to the EFI shell, you can chain-load back to the memstick by executing:

OK lsdev
OK set currdev=disk0s2a
OK boot

ASIDE: If you have an encrypted ZFS volume, simply press ENTER when prompted for partition passphrase. Repeat pressing ENTER at each passphrase prompt until you are presented with a 5-second countdown to reboot. Interrupt said countdown to reach the OK prompt (the EFI shell)

The BIOS on the Framework 12 laptop is InsydeH20 and the version I am running is LFR20.03.04

Laptop purchased April 2026
Comment 1 Warner Losh freebsd_committer freebsd_triage 2026-05-15 16:12:22 UTC
This sounds fairly familiar...

So are you choosing the usb to boot off of, but it winds up seeming to boot off the nvme device instead?  Is that what I understand?
Comment 2 Devin Teske freebsd_committer freebsd_triage 2026-05-15 19:49:15 UTC
(In reply to Warner Losh from comment #1)

Yes, that's right.
Comment 3 Devin Teske freebsd_committer freebsd_triage 2026-05-19 23:27:29 UTC
Update:

14.4-STABLE media is not effected.

16.0-CURRENT is.

Somewhere in-between stable/14 and head, there must be a change.

Replication steps:

1. Insert 14.4-STABLE USB memstick
2. Spam F12 during power on
3. Select USB from boot menu
4. USB boots

NB: if NVMe has encrypted ZFS, you'll first be prompted for the passphrase for the NVMe -- regardless of the fact you are booting from USB -- you can either choose to enter the passphrase or not (makes no difference, either way the USB successfully boots)

then repeat with 16.0-CURRENT memstick

1. Insert 16.0-CURRENT USB memstick
2. Spam F12 during power on
3. Select USB from boot menu
4. NVMe boots

NB: if NVMe has encrypted ZFS, you'll first be prompted for the passphrase for the NVMe -- regardless of the fact you asked to boot USB -- you can either choose to enter the passphrase or not (makes no difference, either way the NVMe boots).

With 16.0-CURRENT, the only way that I have found to boot the USB drive after EFI has been installed, is to cancel the passphrase prompt (repeatedly) until you get the EFI 5-second countdown which can be interrupted to get the EFI shell and chain-load to the USB by altering currdev before calling boot.
Comment 4 Faraz Vahedi freebsd_committer freebsd_triage 2026-05-23 13:40:41 UTC
This isn’t Framework/Insyde-specific. It’s loader.efi on main with default RELAXED policy and the try-all-ZFS-pools behavior (d69fc3a / 784150f). 14.4-STABLE is not affected since it still limits ZFS currdev to the boot device’s pool.

I'm preparing a patch and will notify you when it's ready. The smallest change would be defaulting boot_policy to STRICT in loader.efi. Warner already flagged that "STRICT may be needed for releases" when the relaxed ZFS search was added — see the description of commit 784150f (from review D55107; related discussion in review D55979 as well). But I'm looking at reordering find_currdev() so that partitions on the boot device (UFS on the memstick) are tried before foreign ZFS pools when the policy is RELAXED. This would preserve the multi-pool / spare-member goals of d69fc3a / 784150f while fixing install-media boot.

How to reproduce the problem on macOS running VMware Fusion Pro:

1. Download the 16.0-CURRENT and 14.4-STABLE memstick images.
2. Convert each into a .vmdk file using qemu-img.
3. Add an Existing Hard Disk for each and load the respective .vmdk.
4. Install FreeBSD onto the VM (assuming your disk1 is clean).
5. Go to Settings > Other > Startup Disk, select Hard Disk 2, and choose the 16.0-CURRENT .vmdk from step 2.
6. Verify that the VM incorrectly boots from Hard Disk 1 (the installed OS), ignoring the configured boot order.
7. Go to Settings > Other > Startup Disk, select Hard Disk 3, and choose the 14.4-STABLE .vmdk from step 2.
8. Verify that the VM correctly boots from Hard Disk 3, respecting the configured boot order.

How to apply the workaround to the attached 16.0-CURRENT .vmdk:

1. Boot from the installed FreeBSD instance.
2. Mount Hard Disk 2's EFI partition:
   mount -t msdosfs /dev/nda1p1 /mnt
3. Create the FreeBSD loader environment file and set boot_policy=strict:
   mkdir -p /mnt/EFI/freebsd
   printf 'boot_policy=strict\n' > /mnt/EFI/freebsd/loader.env
4. Reboot and verify that 16.0-CURRENT now boots correctly from Hard Disk 2.
Comment 5 Faraz Vahedi freebsd_committer freebsd_triage 2026-05-26 15:49:06 UTC
I’ve submitted a patch for this fix. Reviews would be appreciated.

https://github.com/freebsd/freebsd-src/pull/2239
Comment 6 Devin Teske freebsd_committer freebsd_triage 2026-05-31 21:40:15 UTC
Thank you so much Faraz for doing the deep dive on this.

On my 16.0-CURRENT install, I have replicated the steps.

> 1. Boot from the installed FreeBSD instance.
> 2. Mount Hard Disk 2's EFI partition:
>    mount -t msdosfs /dev/nda1p1 /mnt
> 3. Create the FreeBSD loader environment file and set boot_policy=strict:
>    mkdir -p /mnt/EFI/freebsd
>    printf 'boot_policy=strict\n' > /mnt/EFI/freebsd/loader.env
> 4. Reboot and verify that 16.0-CURRENT now boots correctly from Hard Disk 2.

Step 2 resulted in Operation not permitted, because it was already mounted at /boot/efi

$ df -hT /boot/efi
Filesystem         Type       Size    Used   Avail Capacity  Mounted on
/dev/gpt/efiboot0  msdosfs    256M    1.3M   255M      1%    /boot/efi

Step 3, we can see in /boot/efi/efi/freebsd there is loader.efi

$ ls /boot/efi
efi
$ ls /boot/efi/efi
boot    freebsd
$ ls /boot/efi/efi/boot
bootx64.efi
$ file /boot/efi/efi/boot/bootx64.efi
/boot/efi/efi/boot/bootx64.efi: PE32+ executable for EFI (application), x86-64, 10 sections
$ ls /boot/efi/efi/freebsd
loader.efi
$ file /boot/efi/efi/freebsd/loader.efi
/boot/efi/efi/boot/bootx64.efi: PE32+ executable for EFI (application), x86-64, 10 sections

We also saw that there is /efi/boot/bootx64.efi, but it is literally identical:

$ sum /boot/efi/efi/boot/bootx64.efi /boot/efi/efi/freebsd/loader.efi
58050 688 /boot/efi/efi/boot/bootx64.efi
58050 688 /boot/efi/efi/freebsd/loader.efi

But not the same file (different inodes):

$ ls -li /boot/efi/efi/boot/bootx64.efi /boot/efi/efi/freebsd/loader.efi
131635 -rwxr-xr-x  1 root wheel 704000 May 19 16:08 /boot/efi/efi/boot/bootx64.efi
131619 -rwxr-xr-x  1 root wheel 704000 May 19 16:08 /boot/efi/efi/freebsd/loader.efi

And we can see that loader.efi expects loader.env to exist in the same place as loader.efi:

$ file=loader.env
$ strings -n ${#file} /boot/efi/efi/freebsd/loader.efi | grep $file$
/efi/freebsd/loader.env
$ strings -n ${#file} /boot/efi/efi/boot/bootx64.efi | grep $file$
/efi/freebsd/loader.env

NB: The last command was pedantic -- loader.efi and bootx64.efi are byte-for-byte identical; regardless of which is loaded (manually or otherwise), the expectation is (as you have indicated) loader.env exists in /efi/freebsd

$ echo boot_policy=strict >> /boot/efi/efi/freebsd/loader.env
$ ls -li /boot/efi/efi/freebsd
131619 -rwxr-xr-x  1 root wheel 704000 May 19 16:08 loader.efi
131621 -rwxr-xr-x  1 root wheel     19 May 31 14:11 loader.env
$ cat /boot/efi/efi/freebsd/loader.env
boot_policy=strict

Now I grab what I think is the 16.0 memstick (not the 14.4 memstick; which unfortunately look identical to each other), insert it into my system and confirm its contents:

$ camcontrol devlist
$ gpart show da0
$ gpart show da0s2
$ mount /dev/da0s2a /mnt

Followed by:

$ grep ^USERLAND_VERSION /mnt/bin/freebsd-version
USERLAND_VERSION="16.0-CURRENT"

Excellent, I grabbed the correct memstick.

Then rebooting, ...

Still booted from the internal disk when I selected USB.

Instructions were not clear, maybe by "the attached 16.0-CURRENT .vmdk" you meant I should have modified the memstick's EFI partition. That seems like it would make more sense, so let me try that.

$ camcontrol devlist
$ gpart show da0
$ mount -t msdosfs /dev/da0s1 /mnt

Mounted the EFI partition, checking it out:

$ ls /mnt
EFI
$ ls /mnt/EFI
BOOT
$ ls /mnt/EFI/BOOT
bootia32.efi    bootx64.efi
$ ls -li /mnt/EFI/BOOT
16931 -r-xr-xr-x  1 root wheel 677376 May  5 02:16 bootia32.efi
16933 -r-xr-xr-x  1 root wheel 704000 May  5 02:16 bootx64.efi
$ file=loader.env
$ strings -n ${#file} /mnt/EFI/BOOT/bootx64.efi | grep $file$
/efi/freebsd/loader.env

As suspected, it wants the loader.env file in the same place.

$ mkdir /mnt/EFI/freebsd
$ echo boot_policy=strict >> /mnt/EFI/freebsd/loader.env
$ ls -li /mnt/EFI/freebsd
60115 -rwxr-xr-x  1 root wheel 19 May 31 14:31 loader.env
$ cat /mnt/EFI/freebsd/loader.env
boot_policy=strict
$ umount /mnt
$ reboot

Then I spam F12 on boot, select USB, and ... (drum roll, please):

IT WORKS!

Altering boot_policy to be strict for the memstick loader allows the installer to be booted when selected as the boot device!

Let's try a few things.

First, I remove the loader.env file off my NVMe. Should not be required to get the correct results. From the memstick's holographic shell (Alt+F4):

$ camcontrol devlist
$ gpart show nda0
$ mount -t msdosfs /dev/nda0p1 /mnt
$ ls /mnt
efi
$ ls /mnt/efi
boot    freebsd
$ ls /mnt/efi/freebsd
loader.efi      loader.env
$ cat /mnt/efi/freebsd/loader.env
boot_policy=strict
$ rm -f /mnt/efi/freebsd/loader.env
$ reboot

NB: Spams F12 during boot-up, selects USB again to ensure that the loader.env on the memstick installer is all that is needed.

BINGO. Yep. Boots USB as-expected.

I've confirmed the findings, and this is very exciting.

Again, thank you for all your hard work Faraz.

Next steps are for me and potentially others to review the patch.
Comment 7 Warner Losh freebsd_committer freebsd_triage 2026-06-01 03:35:09 UTC
So the short term patch is:

diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 9604f16a2480..2dc7924b9fcd 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -146,7 +146,7 @@ EFI_LOADED_IMAGE *boot_img;
 enum boot_policies {
        STRICT,
        RELAXED,
-} boot_policy = RELAXED;
+} boot_policy = STRICT;

 const char *policy_map[] = {
        [STRICT] = "strict",

The longer term fixes to RELAXED will take a while because so far all attempts don't quite do the right thing in a mixed UFS/ZFS world. The apparently Claude generated one in the pull request is close, but there's something about it that I'm uneasy with.
Comment 8 commit-hook freebsd_committer freebsd_triage 2026-06-01 03:41:00 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a1d78374b5c426d43a287b9523660bce36cb55c8

commit a1d78374b5c426d43a287b9523660bce36cb55c8
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-06-01 03:34:59 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-06-01 03:38:58 +0000

    stand: Revert the EFI loader back to strict mode

    The change to relaxed mode has had too many unintended breakages. Revert
    back to strict mode until that works for all the cases that are
    currently broken.

    Fixes: 784150fd2535, d69fc3a9dc71
    PR:  295289
    Sponsored by: Netflix

 stand/efi/loader/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 9 Tomoaki AOKI 2026-06-01 13:59:50 UTC
Doesn't this smell like what smh@ fixed boot1.efi on review D5108 years ago?

Related thread at freebsd-current ML:
https://lists.freebsd.org/pipermail/freebsd-current/2016-January/059387.html
Comment 10 Warner Losh freebsd_committer freebsd_triage 2026-06-01 17:52:03 UTC
(In reply to Tomoaki AOKI from comment #9)
Not the same thing as the boot1.efi from years ago. It's vaguely similar, sure, but not quite the same thing.

We recently thought we could relax what loader.efi did to cover a case that we needed to work at $JOB. Turns out, we were wrong, so I just switched the default to strict until the RELAXED mode works properly for use cases we don't care about for $JOB's deployment and aren't right.

So I'm waiting for there to be a snapshot and I'll close this bug once it's confirmed we've reverted to the prior behavior.
Comment 11 Warner Losh freebsd_committer freebsd_triage 2026-06-01 17:55:04 UTC
Note, this is a bug only with -current / 16. It wasn't in the 15 branch and doesn't affect 15 at all. If you have a problem using the boot loader from 14.* or 15.*, please file a separate bug, because it will have a separate root cause than this one.
Comment 12 Tomoaki AOKI 2026-06-02 10:18:31 UTC
(In reply to Warner Losh from comment #11)
Not bitten at all currently.

Just saw the commit log and attracted, visited here and found what happening looks like old regression I've pointed.

Sorry for the noise!
Comment 13 Faraz Vahedi freebsd_committer freebsd_triage 2026-06-02 11:24:20 UTC
(In reply to Devin Teske from comment #6)

> Instructions were not clear

You’re right, my mistake. Those steps were all VM-specific, as mentioned earlier in the comment.

With “applying the workaround to the attached .vmdk” for example, I meant modifying the memstick's ESP, not the local disk’s. That also explains why your step 2 failed, you were targeting the wrong ESP for the test case: the intention was not to modify the existing system ESP, but the one on the memstick image instead.

I’ve learnt all of this from you, so apologies for revisiting it: at boot, the firmware loads the EFI binary from the USB’s ESP and then reads /efi/freebsd/loader.env from that same ESP. As such, the one on the local machine is not part of this boot path and has no bearing on the issue.

Again, my apologies for the confusion.
Comment 14 Faraz Vahedi freebsd_committer freebsd_triage 2026-06-02 11:34:01 UTC
(In reply to Warner Losh from comment #7)

> The longer term fixes to RELAXED will take a while because so far all attempts don't quite do the right thing in a mixed UFS/ZFS world.

I might be wrong, but all my tests proved they do (unless I've missed something, in which case I'd appreciate it if you educate me.) Please check comment #13 as well; I was unable to fully convey the exact instructions here, so my apologies for any confusion that caused.

> The apparently Claude generated one in the pull request is close

That document took me hours to write, test, and polish. Not that I'm opposed to AI, but your assumption stung a little.

> but there's something about it that I'm uneasy with.

If there's anything you're uncertain or uneasy with, I'd appreciate you raising it so I can help. I may not be as experienced as you all, but I might still be able to help.
Comment 15 Warner Losh freebsd_committer freebsd_triage 2026-06-02 14:02:40 UTC
(In reply to Faraz Vahedi from comment #14)

First off, please accept my apologies for casting aspersions on the pull request. I've been plowing through a lot of things so created and there were some features that lead me to a wrong assertion. I do very much appreciate your efforts. And the submission looks quite good.

I'll put my comments about the code on the review. I had a little time this morning before an offsite.

Again, please accept my apologies for the false positive.
Comment 16 Faraz Vahedi freebsd_committer freebsd_triage 2026-06-02 22:33:20 UTC
(In reply to Warner Losh from comment #15)

> First off, please accept my apologies for casting aspersions on the pull request. I've been plowing through a lot of things so created and there were some features that lead me to a wrong assertion.

No worries, it's OK. I've come across quite a few similar cases, so I get the frustration. Thanks for caring and reaching out. It means a lot.

> I do very much appreciate your efforts. And the submission looks quite good.

So chuffed to hear that, cheers.

> I'll put my comments about the code on the review. I had a little time this morning before an offsite.

I'll check your comments and do my best to address them tomorrow, thanks!