upgrade to 25.7 -> bootloader too old

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

Previous topic - Next topic
Quote from: Patrick M. Hausen on July 28, 2025, 09:56:40 PMPlan some time for a reinstallation with ZFS and a reasonably large EFI partition ;-)

First of all, thanks for all your help! Just a question for the future - do I understand you correctly that if the boot partition is 512K it would be a good idea to plan for a repartitioning followed by a reinstall at some convenient point in the future? I run ZFS and my gpart output looks like this:
# gpart show -l
=>       40  234441568  ada0  GPT  (112G)
         40     532480     1  efiboot0  (260M)
     532520       1024     2  gptboot0  (512K)
     533544        984        - free -  (492K)
     534528   16777216     3  swap0  (8.0G)
   17311744  217128960     4  zfs0  (104G)
  234440704        904        - free -  (452K)
(I realise that the boot partition size is not a current issue but a theoretical future one.) I don't suppose there is a way to do a repartitioning in situ without a full reinstall?
OPNsense 25.1.9_2-amd64 on APU2E4 using ZFS

@beneix may I ask when you installed your system?

I thought that newer installer images create a bigger bootfs partition... If that's not the case, maybe there is a way to change that during install.

I first set up my OPNsense install in August 2022, which means 22.7, and it made a 260MB EFI partition at the time. I'm assuming that was done by the OPNsense installer, as I don't remember having the ability to change partition sizes.

July 29, 2025, 08:40:43 AM #48 Last Edit: July 29, 2025, 08:43:26 AM by beneix
Quote from: tessus on July 29, 2025, 07:47:34 AM@beneix may I ask when you installed your system?
The system was purchased in 2022 and I installed UFS. Then in 2024 I decided to take the leap and re-install with ZFS - I think it was when 24.7.1 was out. I don't recall giving any particular input to sizing, I think I just let the installer set the defaults, but I could be wrong.
OPNsense 25.1.9_2-amd64 on APU2E4 using ZFS

July 29, 2025, 09:00:19 AM #49 Last Edit: July 29, 2025, 10:34:54 AM by tessus
Thanks for the info.

Please ignore the next paragraph. (Keeping it for some laughs.) I must have been out of my mind...
The bootloader is not in the EFI partition but in the bootfs partition. When I installed OPNsense in 2021, the bootloader was less than 300KB and now it's 658432 bytes. I am a bit fuzzy as to why it says 512KB for my bootfs partition, because when I mount it, it's actually 779K. So I am really lucky, because otherwise the 658432 bytes wouldn't have fit. But according to most manuals, one should actually copy the loader twice and this will definitely not work with the current 512KB bootfs partition. So in a few years the bootloader is bigger than the partition and then it's over.

You cannot mount the legacy boot loader partition. It does not contain a file system. That's the partition you write with this command:

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

And if you look at /boot/gptboot or /boot/gptzfsboot they are way below 200k in size so a 512k partition is more than enough.

What you can mount is EFI partition which is FAT32 formatted. And 779k is too small for that nowadays. 260M as the OPNsense installer creates now, OTOH, is again more than enough.

Partition 2: legacy boot loader - 512k
Partition 1: EFI - 260M

"bootfs" is just a label, it does not in any way say that there is an actual file system on that one.

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

Patrick, you told me to add the following to my fstab:

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

I did that and when I mounted it, df showed me the following:

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    644K    135K    83%    /boot/efi

So something is wrong with your last comment, because I mounted the legacy bootloader with the commands you gave me.

Th only other explanation is that my 200MB EFI partition has a 779K msdos filesystem on it, which makes no sense. Once again, here is my gpart output:

gpart show
=>       40  234441568  ada0  GPT  (112G)
         40     409600     1  efi  (200M)
     409640       1024     2  freebsd-boot  (512K)
     410664  215567272     3  freebsd-ufs  (103G)
  215977936   16777216     4  freebsd-swap  (8.0G)
  232755152    1686456        - free -  (823M)

That can well be the case, if the partition was installed with "dd" of a precreated FAT32 image as FreeBSD used to do some time ago.

To fix that, assuming you have the fstab entry in place:

newfs_msdos /dev/ada0p1
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

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

Ha, ok. This is interesting. I thought that I mounted the 2 partition for some reason, since the size was very close to the 512K. And who knows what weird byte calculations OSes do these days. e.g. I grew up with base-2 sizes and not using the i size notation. These days, it's a mess, especially because often the wrong units are used. Very annoying and confusing.

Quote from: tessus on July 29, 2025, 09:59:41 AMPatrick, you told me to add the following to my fstab:

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

I did that and when I mounted it, df showed me the following:

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    644K    135K    83%    /boot/efi

So something is wrong with your last comment, because I mounted the legacy bootloader with the commands you gave me.

ada0p1 is the EFI partition, the legacy boot loader is ada0p2. You cannot mount the legacy boot loader. It's not a file system.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)