Error: "Loader need to be updated" on boot in various combinations

From: Christopher Sean Hilton <chris_at_vindaloo.com>
Date: Tue, 24 Dec 2024 16:09:03 UTC
I'm in the process of updating a set of machines from FreeBSD 13.2 and FreeBSD 13.3 to
13.4. If the machine starts on 13.2, then my process is:

    ```
    # freebsd-update upgrade -r 13.3-RELEASE
    ...
    # freebsd-update install; reboot
    ...
    # freebsd-update install

    ...
    # freebsd-update upgrade -r 13.4-RELEASE
    ...
    ```

I haven specifically watched, but I will next time, but when I do this I end up with a
machine that boots fine but sends the message:

- "Loader needs to be updated"

All of the machines are VMs running of VMware Fusion or ESXi so I can Snapshot the machines
leaving me free to do some experimentation in my search for a solution. However, searching
around the internet hasn't produced a solution to this problem. I'll give two examples:

One of the machines is an aarch64 VM with ZFS root filesystem.

    ```
    $ gpart show
    =>      40  83886000  nda0  GPT  (40G)
            40    532480     1  efi  (260M)
        532520      2008        - free -  (1.0M)
        534528  33554432     2  freebsd-swap  (16G)
      34088960  49795072     3  freebsd-zfs  (24G)
      83884032      2008        - free -  (1.0M)

    =>       40  268435376  nda1  GPT  (128G)
             40   33554432     1  freebsd-swap  (16G)
       33554472  234880944     2  freebsd-zfs  (112G)

    $ mount | egrep efi
    /dev/gpt/efiboot0 on /boot/efi (msdosfs, local)
    $
    ```

I've copied `/boot/loader.efi` to both `/boot/efi/efi/freebsd/loader.efi` and
`/boot/efi/efi/boot/bootaa64.efi`. The `efibootmgr -v` command reports that the
`.../freebsd/loader.efi` file is the one in use. Unfortunately, this didn't fix the problem.

----------------------------------------

My second machine is an amd64 VM with a UFS root filesystem:

    ```
    $ gpart show
    =>      40  33554352  da0  GPT  (16G)
            40      1024    1  freebsd-boot  (512K)
          1064   2096128    2  freebsd-ufs  (1.0G)
       2097192   8388608    3  freebsd-swap  (4.0G)
      10485800  12582912    4  freebsd-ufs  (6.0G)
      23068712   2097152    5  freebsd-ufs  (1.0G)
      25165864   8388528    6  freebsd-ufs  (4.0G)

    $
    ```

I found a [post on the FreeBSD
forums](https://forums.freebsd.org/threads/update-of-the-bootcodes-for-a-gpt-scheme-x64-architecture.80163/)
that suggested using gpart as follows:

    `gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0`

Again, since this is a virtual machine, and honestly not a hard one to rebuild, I took a
snapshot, fired off the gpart command, and again found the "Loader needs to be updated"
error message.

----------------------------------------

I understand that there are lots of different situations here. I'm willing to fork my
question into two questions to keep things easy to follow.


**Q:** _What's the root cause here?_ It seems like I'm not addressing the root cause.


-- 
Chris

      __o          "All I was trying to do was get home from work."
    _`\<,_           -Rosa Parks
___(*)/_(*)____.___o____..___..o...________ooO..._____________________
Christopher Sean Hilton                    [chris/at/vindaloo/dot/com]