hosed myself by doing zpool upgrade

Started by fbfarms, May 29, 2025, 10:48:35 PM

Previous topic - Next topic
I foolishly did a "zpool upgrade" a while back not realizing that was problematic in freebsd.  We lost power last night for longer than the UPS had battery and I woke up this morning to no internet with a "ZFS - can't find GUID problem" that is related to the boot loader being confused after the pool upgrade.  I was able to get back up and running sorta by booting a live USB and running the importer and using the "zroot" drive option so the pool is still there - but the importer just does the basics like firewall rules.  I have a ton of haproxy and letsencrypt stuff setup that I need to preserve.  A few questions:

1. Does anybody know how to fix the boot loader problem - that seems simplest but the various things I tried didn't seem to work.

2. I wouldn't be against reinstalling particularly because back when I did the initial install many years ago the installer wasn't smart enough to do a mirror ZFS setup but I think it is now - but I'm not that familiar with how the "installer" mode works - is it smart enough to see my previous installation and copy all the configs including the haproxy/acme.sh stuff or will it just do the basics like the live mode did?  If the later, how is the easiest way to manually save that stuff so I don't have to recreate it from scratch?

Advice???  The system in questions running latest greatest 25.1.7_4.


Quote from: fbfarms on May 29, 2025, 10:48:35 PM1. Does anybody know how to fix the boot loader problem - that seems simplest but the various things I tried didn't seem to work.

That's quite simple, actually. You need to copy the current boot loader to your drive. You did not provide the details of your pool topology, so I am assuming you are running the OPNsense default install on a single drive. Correct?

Anyway you need a system with a current boot loader up and running. If you can afford the downtime, just boot your system with a FreeBSD 14.2 image from USB.

Then check with

Quotegpart show

what your partition layout looks like. Mine is this:

root@opnsense:~ # gpart show
=>       40  500118112  nda0  GPT  (238G)
         40     532480     1  efi  (260M)
     532520       1024     2  freebsd-boot  (512K)
     533544        984        - free -  (492K)
     534528   16777216     3  freebsd-swap  (8.0G)
   17311744  482805760     4  freebsd-zfs  (230G)
  500117504        648        - free -  (324K)

So we have an EFI partition and a legacy boot partition and since we do not know how your system boots we will update both of them. Replace the device names as fits your system. I assume you have a shell in a current FreeBSD 14.2 system, checked your partition layout and know which partition contains what. E.g. EFI is partition 1 and legacy is partition 2 - adjust if necessary. Same for the device ("nda0" in my case).

# update legacy boot code
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 2 nda0
# update EFI boot code
mount -t msdosfs /dev/nda0p1 /mnt
mkdir -p /mnt/efi/boot /mnt/efi/freebsd
cp /boot/loader.efi /mnt/efi/boot/bootx64.efi
cp /boot/loader.efi /mnt/efi/freebsd/loader.efi
umount /mnt

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

Thank you - that worked!  I did have to manually reformat the EFI partitions because I think i had corrupted them in my earlier attempts - but I'm now up and working again.