RPi3 with UEFI?

Hi all,

I’ve had a pretty good experience with UEFI booting my Pi4 (ZFS root on USB SSD, initially grub now systemd-boot), so I decided to try it on my Pi3 as well, which is BTRFS root also on a USB SSD.

Using GitHub - pftf/RPi3: Raspberry Pi 3 UEFI Firmware Images, not having any luck.

Apparently the Pi3 bootloader requires MBR instead of GPT, and systemd-boot refuses to work with MBR.

I thought it would be no big deal – just use grub, but grub doesn’t seem to be producing any code in the EFI partition (I’m expecting something like efi/boot/bootaa64.efi).

When I run nixos-install, I get no errors, everything looks fine, just doesn’t boot. When I look closer, the boot*.efi file is missing.

When I nixos-enter into the image and manually NIXOS_INSTALL_BOOTLOADER=1 switch-to-configuration, I get the error below:

# NIXOS_INSTALL_BOOTLOADER=1 /run/current-system/bin/switch-to-configuration switch
updating GRUB 2 menu...
ERROR: Could not search B-tree: Function not implemented
Failed to retrieve subvolume info for /boot
Failed to install bootloader

BTRFS scrub comes up clean, the devices seems to mount and read normally.

I see that error string in btrfs-progs: btrfs-progs/libbtrfsutil/errors.c at a1926e39df13813ea4130f656a72b6052072848e · kdave/btrfs-progs · GitHub

Is anyone else using UEFI on a NixOS Pi3? If so, what’s your setup?

TIA!

My setup has:

  • systemd-boot
  • LUKS encrypted ext4 root
  • GPT with Hybrid MBR

I have a post on the general installation process:
https://prince213.top/blog/2025/01/21/nixos-rpi/
And this is my disk configuration with disko:
https://git.sr.ht/~prince213/dotfiles/tree/main/item/systems/pegasus/disk.nix

Did you make sure to set boot.loader.efi.canTouchEfiVariables = false; and boot.loader.grub.efiInstallAsRemovable = true;?

It also kinda sounds like your /boot partition isn’t mounted?

1 Like

That sounds like GRUB is trying to write to a btrfs-formatted /boot?

Edit: @ElvishJerricco sniped me :stuck_out_tongue:

Awesome, I will look into this!

I’d seen a post about a related setup: Booting a Raspberry Pi 3B with UEFI and a Hybrid MBR | Eisfunke

Yes (and also tried switching these around and back).

It is mounted. EDIT: (It is a top-level BTRFS subvolume.)

Yes – @boot is a top-level subvolume mounted to /boot, with a FAT partition at /boot/efi. I’ve used this setup on my Pi4 (and other BTRFS-root UEFI machines) without issue.

Also previously was working well via u-boot, as long as I compiled in the BTRFS (and ZSTD) bits: GitHub - n8henrie/nixos-btrfs-pi: Raspberry Pi SD card image for NixOS on BTRFS root

Stuff like this is exactly why I tell people to just use systemd-boot and to mount the ESP at /boot. It’s so much simpler and you don’t have to deal with grub screwing things up half the time.

I mentioned above – systemd-boot refuses to install due to being MBR, so includes some additional levels of complexity (figuring out GPT with Hybrid MBR). Unless you’re aware of a way to get systemd-boot to work with the standard RPi3 MBR setup?

A Hybrid MBR setup seems to be working well, thanks to @Prince213 for the suggestion.

I ended up following the guide at Booting a Raspberry Pi 3B with UEFI and a Hybrid MBR | Eisfunke for my setup, as it spelled things out a little more elaborately.