Solved Can't boot after zpool upgrade

Uhm, since originally the machine (running 11.4) had both efi & freebsd-boot partitions, is there any chance that 13.0 booted from the efi partition previously initialized by 11.x?
Code:
=>        40  1875384928  nvd0  GPT  (894G)
          40        1600     1  efi  (800K)
        1640        1024     2  freebsd-boot  (512K)
        2664        1432        - free -  (716K)
        4096    16785408     3  freebsd-swap  (8.0G)
    16789504  1858594816     4  freebsd-zfs  (886G)
  1875384320         648        - free -  (324K)
Your EFI partition is 800K. Please note that 13.0 EFI loader is a bit over 800K. You need to grow this partition to fit new 13.0 EFI loader (/boot/loader.efi). Also, 13.0 loader is backward compatible and can boot 12.x pools.
 
Thanks! I'm busted.


$ sysctl machdep.bootmethod
machdep.bootmethod: UEFI
$


Is there a chance that with the (now) corrupt/non-functional UEFI partition it will fall back to partition 2, which is freebsd-boot? (gptzfsboot)

It feels like I'll need to get my hands dirty and re-initialize this UEFI stuff. The Handbook doesn't say much about how to set this up: https://docs.freebsd.org/en_US.ISO8859-1/books/handbook/boot-introduction.html
There's also some food for thought on Wiki: https://wiki.freebsd.org/UEFI
This is it? The 1st partition needs to be type msdosfs and contain the single file /EFI/BOOT/BOOTX64.efi (copied from /boot/loader.efi)?
 
Your EFI partition is 800K. Please note that 13.0 EFI loader is a bit over 800K. You need to grow this partition to fit new 13.0 EFI loader (/boot/loader.efi).
Oh no. Indeed /boot/loader.efi is 896000 bytes in size.
Does this mean I need to drop the second partition and recreate partition 1 as efi? Is this even legal? :)))
 
Oh no. Indeed /boot/loader.efi is 896000 bytes in size.
Does this mean I need to drop the second partition and recreate partition 1 as efi? Is this even legal? :)))
This means that you need a bigger partition for EFI loader.

EDIT: sorry my original post. You need to find that space. For example you can take some space off the SWAP.
 
On 13, you can still install /boot/boot1.efi instead of /boot/loader.efi. It's deprecated (will probably be gone in 14) and lacks a few features like booting from GELI, bit it's small, so a 800k partition is enough.
 
Oh, is /boot/boot1.efi a replacement for /boot/boot1.efifat? Thanks!

Code:
$ sudo gpart bootcode -p /boot/boot1.efi -i 1 nvd0
partcode written to nvd0p1
$

To reboot or not to reboot, that is the question :)
 
EDIT: sorry my original post. You need to find that space. For example you can take some space off the SWAP.


Can't I delete the freebsd-boot partition and resize the 1st UEFI to be 896000 bytes in size?

Code:
$ gpart show
=>        40  1875384928  nvd0  GPT  (894G)
          40        1600     1  efi  (800K)
        1640        1024     2  freebsd-boot  (512K)
        2664        1432        - free -  (716K)
        4096    16785408     3  freebsd-swap  (8.0G)
    16789504  1858594816     4  freebsd-zfs  (886G)
  1875384320         648        - free -  (324K)


This is if /boot/boot1.efi isn't an option. I would choose it as it's simpler.

Code:
$ ll /boot/boot1.efi
-r-xr-xr-x  1 root  wheel  114176 Apr 12 13:36 /boot/boot1.efi
$
 
Can the fact that the partcode/bootcode written by gpart to a 819200-byte long partition is only 114176 bytes long? (/boot/boot1.efi)
 
Oh, is /boot/boot1.efi a replacement for /boot/boot1.efifat? Thanks!
No. boot1.efifat was a FAT image to be written directly to partition. This is deprecated. Today you need to format EFI partition, mount it and create EFI folder in it. See the manuals.

file /boot/boot1.efi
/boot/boot1.efi: PE32+ executable (EFI application) x86-64, for MS Windows
 
Oh, is /boot/boot1.efi a replacement for /boot/boot1.efifat? Thanks!

Code:
$ sudo gpart bootcode -p /boot/boot1.efi -i 1 nvd0
partcode written to nvd0p1
$

To reboot or not to reboot, that is the question :)
NO. You have overwritten your FAT partition with file!

Now format the partition first
newfs_msdos -F 32 -c 1 /dev/nvd0p1

Then mount it

mount -t msdosfs /dev/nvd0p1 /mnt

Create folder

mkdir -p /mnt/EFI/BOOT

Copy boot loader

cp /boot/boot1.efi /mnt/EFI/BOOT/BOOTX64.efi
 
I can't create vfat on that 800kb sized partition.

$ sudo newfs_msdos -F 32 -c 1 /dev/gpt/efiboot0
newfs_msdos: 1542 clusters too few clusters for FAT32, need 65525
$

Steps taken from https://wiki.freebsd.org/UEFI

But someone did create it ) It's a 2 disk GEOM mirror, 2nd disk's 1st partition is still intact since I was writing to the underlying device directly.

$ sudo file -s /dev/nvd1p1
/dev/nvd1p1: DOS/MBR boot sector, code offset 0x3c+2, OEM-ID "BSD4.4 ", root entries 512, sectors 1575 (volumes <=32 MB), sectors/FAT 5, sectors/track 63, heads 1, serial number 0x5b811818, label: "EFI ", FAT (12 bit), followed by FAT


So fat12 or 16 are ok for EFI?
 
boot1.efifat was a filesystem image containing boot1.efi.

Both are deprecated, but boot1.efi still exists in 13 and can be used if you don't need features like GELI boot.

Edit: yes fat12 is ok as long as your uefi bios doesn't insist on fat32. If it would, booting would have never worked with such a small partition.
 
Here's what I did:

Code:
$ sudo newfs_msdos -F 12 -c 1 /dev/gpt/efiboot0
/dev/gpt/efiboot0: 1557 sectors in 1557 FAT12 clusters (512 bytes/cluster)
BytesPerSec=512 SecPerClust=1 ResSectors=1 FATs=2 RootDirEnts=512 Sectors=1600 Media=0xf0 FATsecs=5 SecPerTrack=63 Heads=255 HiddenSecs=0
$ sudo mount -t msdosfs /dev/nvd0p1 /mnt
$ ll /mnt
total 0
$ df -h /mnt
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/nvd0p1    780K    1.0K    779K     0%    /mnt
$ sudo mkdir -p /mnt/EFI/BOOT
$ sudo cp /boot/boot1.efi /mnt/EFI/BOOT/BOOTX64.efi
$ df -h /mnt
Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/nvd0p1    780K    114K    666K    15%    /mnt
$ sudo umount /mnt
$


Can I now cross my fingers and reboot? Does anything need to be done, like making the partition active?
Oh, and probably I need to do the same steps on the zfs mirror disk.
 
Oh, I can see the contents of the original EFI partition on the second disk:

Code:
$ ll /mnt/EFI/BOOT/
total 129
-rwxr-xr-x  1 root  wheel  131072 Apr 13  2016 BOOTX64.EFI
-rwxr-xr-x  1 root  wheel      12 Apr 13  2016 STARTUP.NSH
$ cat /mnt/EFI/BOOT/STARTUP.NSH
BOOTx64.efi
$

How important is this STARTUP.NSH file? Should I add it too?
And damn! The file's name is all caps, while the contents of STARTUP.NSH is miXeD case. And yet this all worked :)
 
Yep that's all fine. Just remember boot1.efi is deprecated as well, so I'd expect it to be removed in FreeBSD 14. Then you'll have no other choice than a larger EFI partition. But at least, this will be a few years ;)
 
Thanks, guys, this is a machine from a datacenter so I suppose they will upgrade their partitioning scheme to be in line with newer FreeBSD's.
Also I have an option to experiment with upgrading FreeBSD 11.4 to 13.0 & upgrading zpool on another of their machines, in case something goes wrong their basic installation of 11.4 can be re-deployed from the console easily. If the steps I did above work fine there I will reboot this one too.
 
Yaaaaayyyy! The new machine installed from scratch and freebsd-updated 11.4 -> 13.0 followed by zpool upgrade & efi trickery above worked!!! The other machine restarted fine too. Thank you so much, everyone who helped with this!
 
Back
Top