upgrade to 25.7 -> bootloader too old

Started by mnaim, July 26, 2025, 01:52:07 AM

Previous topic - Next topic
July 28, 2025, 04:54:21 PM #15 Last Edit: July 28, 2025, 05:03:35 PM by Chunkers
Sorry duplicate post

Quote from: Chunkers on July 28, 2025, 04:54:21 PMHi all,

I am unable to upgrade to 25.7, it very quickly becomes unstable and crashes. I am have made several attempts by doing a full reinstall and uploading my config.xml and now need to try something different before trying again !

I am also not very familiar with FreeBSD, I would be very grateful for advice on suggested changes, here are the outputs for my router :

Quoteroot@opnsense:~ # sysctl machdep.bootmethod
machdep.bootmethod: UEFI

Quoteroot@opnsense:~ # gpart show -l
=>      40  488397088  nda0  GPT  (233G)
        40        24        - free -  (12K)
        64    532480    1  efifs  (260M)
    532544      1024    2  bootfs  (512K)
    533568  471086448    3  rootfs  (225G)
  471620016        16        - free -  (8.0K)
  471620032  16777096    4  swapfs  (8.0G)

Quoteroot@opnsense:~ # cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/gpt/rootfs /              ufs    rw      1      1
/dev/gpt/efifs  /boot/efi              msdosfs rw      2      2
/dev/gpt/swapfs none            swap    sw      0      0

Quoteroot@opnsense:~ # uname -a
FreeBSD opnsense.home 14.2-RELEASE FreeBSD 14.2-RELEASE stable/25.1-n269614-36155813721 SMP amd64

Any advice would be most appreciated, I have reinstalled 25.1 and my router is running well for now now but I am unable to upgrade

Thank you

Chunks


The boot loader is not in any way connected to instability of the running system. If a newly installed 25.7 boots, the loader is fine.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)


July 28, 2025, 05:28:41 PM #19 Last Edit: July 28, 2025, 05:30:21 PM by julsssark
Thanks @Patrick for the helpful information. I've been using OPNsense for 3 years and did not know about this.

Thanks @Slashing for posting that utility. The utility can also be used to update the boot loaders. It worked great for me.

Quote from: Slashing on July 28, 2025, 01:39:12 AMHello! There is a small utility for checking the bootloader.
I have never compiled anything from scratch on my OPNsense system. How would I go about installing this utility?
OPNsense 25.1.9_2-amd64 on APU2E4 using ZFS

Quote from: beneix on July 28, 2025, 06:00:16 PM
Quote from: Slashing on July 28, 2025, 01:39:12 AMHello! There is a small utility for checking the bootloader.
I have never compiled anything from scratch on my OPNsense system. How would I go about installing this utility?
No compilation required, it's just a script. Download it, chmod +x it and run it as root.

Quote from: Slashing on July 28, 2025, 06:51:52 PMNo compilation required, it's just a script. Download it, chmod +x it and run it as root.
Doh! Thanks

So there is a general recommendation to keep your bootloader up-to-date, but I am not sure I understand how this utility achieves this. Am I to understand that there is updated code in one place on the disk but this has not been copied to the right place? My output from the utility is:
One or more efi partition(s) have been found.

Examining ada0p1...
Efi partition ada0p1 is already mounted in /boot/efi.
Would run: cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
Would run: cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi

One or more freebsd-boot partition(s) have been found.
The root file system is zfs.

Examining ada0...
Would run: gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0

-------------------------------
Your current boot method is BIOS.
Updatable EFI loader: 2
Updatable BIOS loader: 1
-------------------------------
OPNsense 25.1.9_2-amd64 on APU2E4 using ZFS

A FreeBSD update installs current boot code matching the operating system and even more importantly ZFS version to the /boot directory.

But this is not what the system actually uses to boot. Due to idiosyncrasies of the PC architecture the boot loader needs to be copied to special partitions depending on the boot method (legacy BIOS or UEFI).

The script supposedly does that.

Your dry run output looks very reasonable. I would give a live run a try - at a convenient time when an outage is not a huge problem.

Cue Riddick: "Looks clear!" :-)

Kind regards,
Patrick

P.S. A default OPNsense installation always creates a legacy and a UEFI boot partition. I advise to keep both up to date. Eventually you will replace your hardware and plan to just swap the SSD to the new system - which uses "the other" boot method. Duh! So keep both updated.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

@Patrick Sure, here you go:

root@cator00r:~ # gpart show -l
=>       40  234441568  ada0  GPT  (112G)
         40     409600     1  (null)  (200M)
     409640       1024     2  bootfs  (512K)
     410664  215567272     3  rootfs  (103G)
  215977936   16777216     4  swapfs  (8.0G)
  232755152    1686456        - free -  (823M)

@tessus add an /etc/fstab entry like so:

/dev/ada0p1    /boot/efi       msdosfs     rw,noauto             2       2

Then:

mkdir -p /boot/efi
mount /boot/efi
mkdir -p /boot/efi/efi/boot /boot/efi/efi/freebsd
cp /boot/loader.efi /boot/efi/efi/boot/bootx64.efi
cp /boot/loader.efi /boot/efi/efi/freebsd/loader.efi
umount /boot/efi

And to update the legacy boot loader:

gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0

That should do it.

HTH,
Patrick
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Thank you.

I do understand the process, but I have 2 questions:

Quote from: Patrick M. Hausen on July 28, 2025, 09:07:27 PMmkdir -p /boot/efi/efi/boot

This directory already existed and had the following entries:

root@cator00r:/boot/efi/efi/boot # ll
total 385
-rwxr-xr-x  1 root wheel 393216 Apr 16  2018 BOOTx64.efi
-rwxr-xr-x  1 root wheel     12 Apr 16  2018 startup.nsh

root@cator00r:/boot/efi/efi/boot # cat startup.nsh
BOOTx64.efi

msdosfs is case-insensitive, so all should be good. Or shall I change the contents of startup.nsh to lowercase?

Quote from: Patrick M. Hausen on July 28, 2025, 09:07:27 PMgpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 ada0

Isn't this for zfs? Shouldn't I rather use (I am still using ufs currently):

gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 2 ada0

First question: mkdir -p makes sure a path exists without throwing an error if it does already. So no problem, I included it for completeness sake.
Second question: yes, probably - my bad. I don't have any UFS based systems, anymore.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

@benix, the utility recommends the commands to run. You'll need to run those commands to do the update. Or you can run the utility with the "shoot-me" option and it will prompt/run each command for you.

July 28, 2025, 09:39:52 PM #29 Last Edit: July 28, 2025, 09:43:56 PM by tessus
I think I just destroyed my system.

It seems the bootfs partition is not big enough:

# df -h
Filesystem                   Size    Used   Avail Capacity  Mounted on
/dev/gpt/rootfs              100G     15G     77G    16%    /
devfs                        1.0K      0B    1.0K     0%    /dev
devfs                        1.0K      0B    1.0K     0%    /var/dhcpd/dev
devfs                        1.0K      0B    1.0K     0%    /var/unbound/dev
/usr/local/lib/python3.11    100G     15G     77G    16%    /var/unbound/usr/local/lib/python3.11
/lib                         100G     15G     77G    16%    /var/unbound/lib
/dev/ada0p1                  779K    779K      0B   100%    /boot/efi

So I was able to update the file in /boot/efi/efi/boot but the there is no more space for the file in /boot/efi/efi/freebsd


The bootfs is just 512KB.

P.S.: my question ws not about mkdir -p but the startup.nsh file