Skip to content

Root + Boot on ZFS + rEFInd, anyone had any luck?

So I’m attempting to get root on ZFS working while booting with rEFInd.

I’ve managed to get Root + Native Encryption working with /boot on ext4.

I have 3 zpools: bpool, rpool and hpool. (Boot, root and home.) Bpool has one dataset mounting to /boot, unencrypted. Rpool has one dataset mounted to / encrypted with a password. Hpool has an encrypted dataset for each user unecrypted with PEM at login.

My esp is mounted at /efi. It is shared with a Windows 10 install, a Manjaro on ext4 install that I recently converted back to an arch install (and where I’ve been building the ZFS install from), and zfsbootmenu.

I cannot get /boot on ZFS discoverable by rEFInd. I’m using the grub2 ZFS driver in rEFInd as per the rEFInd instructions. I can successfully boot from grub, as well as from zfsbootmenu.

I’ve tried manually adding a menu option for the ZFS boot, but I’m not entirely sure what it should look like. And examples are hard to come by.

Wondering if anyone else has had any success with this, or can point me in the right direction for answers.

Edited 25 Feb 2023. We only hold this version.

8 points16 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
8 · 90% up
Kind
Text
ID
11ariit

Author

2
posts
12
comments
0
media
View profile

16 comments

While I do not have answer at hand since I don't use ZFS what wonders me what decrypts your boot, since refind does not support encrypted boot, whereas grub does.

4 points

Boot isn’t encrypted. Root and home are ZFS native encryption. Root gets decrypted when booting with a pass phrase and home gets decrypted on login with PEM.

1 points

I have 3 zpools: bpool, rpool and hpool. (Boot, root and home.) Bpool has one dataset mounting to /boot, encrypted.

My question was based on that. If it is not encrypted you might want to edit it, as it may be a bit confusing.

1 points

I haven't tried the driver, but you can just create a ZFSBootMenu entry for refind and use that. My current setup has both:

  • ZFSBootMenu with my normal options as the default boot method
  • rEFInd with ZFSBootMenu entries as a second boot method in case I break something or want to boot other things

The direct to ZBM entry in the motherbard is new. I only added it because I'm tired of the extra wait time with rEFInd. Before that, I used rEFInd. There was also a windows entry which I've since deleted.

4 points

Interesting! I want to stick with refind because I jump between windows and linux quite a bit. (A side project has been trying to get an easy flow to kexec between the two.)

My plan was to have arch/windows/any live usb/images show up as menu items. Then make a submenu item under the arch menu item with ZBM for recovery.

Where you say you have ZBM entries plural in refind, is that ZBM somehow presenting multiple boot environments/kernels to refind?

1 points

Where you say you have ZBM entries plural in refind, is that ZBM somehow presenting multiple boot environments/kernels to refind?

Sorta. They're both Arch via ZBM, but with slightly different options.

This is what I have at the end of my refind.conf:

# Arch
menuentry "Arch" {
    icon            /EFI/refind/icons/os_arch.png
    volume          "EFI"
    loader          /EFI/zbm/vmlinuz-zbm-bootmenu
    initrd          /EFI/zbm/initramfs-bootmenu.img
    options         "zbm.prefer=Primary!! ro quiet loglevel=3 udev.log_level=3 bgrt_disable vt.global_cursor_default=0 zbm.skip initrd=\EFI\ucode\amd-ucode.img"
    submenuentry    "Backup ZBM" {
	    loader		    /EFI/zbm/vmlinuz-zbm-bootmenu-backup
	    initrd		    /EFI/zbm/initramfs-bootmenu-backup.img
        options         "zbm.prefer=Primary!! ro zbm.skip initrd=\EFI\ucode\amd-ucode.img"
    }

}

# ZBM
menuentry "ZBM" {
    icon            /EFI/refind/themes/illode/zbm.png
    volume          "EFI"
    loader          /EFI/zbm/vmlinuz-zbm-bootmenu
    initrd          /EFI/zbm/initramfs-bootmenu.img
    options         "zbm.prefer=Primary rw zbm.show initrd=\EFI\ucode\amd-ucode.img"
    submenuentry    "Backup ZBM" {
	    loader		    /EFI/zbm/vmlinuz-zbm-bootmenu-backup
	    initrd		    /EFI/zbm/initramfs-bootmenu-backup.img
        options         "zbm.prefer=Primary rw zbm.show initrd=\EFI\ucode\amd-ucode.img"
    }
}

These showcase roughly what you need. The end result was that I had 3 options (excluding subentries) in refind:

  • Boot Windows (I let refind autogenerate this entry)
  • Boot Arch, skipping ZBM
  • Boot Arch, showing ZBM

There's a bunch of other garbage/my setup specific things here, so don't blindly copy it. Particularly the boot options. Some of it does literally nothing, It's just there because I kept forgetting to clean it up. If you use this as a reference though, you should be able to get what you want without too much pain.

As mentioned in my last comment though, I used efibootmgr to add the equivalent of the Arch entry directly to the motherboard. I almost never boot anything else, so now refind is just a backup in case I screw something up.

The only other thing to note is that ZFSBootMenu/kexec can't load additional initrd files. The initrd in the options string does nothing (I think. I can't double check because I update my BIOS). You'll have to either keep your motherboard BIOS updated or concatenate the ucode/initramfs files every time a new initramfs is generated.

2 points

Sounds like a refind question, not an arch one.

3 points

Not even really a refind question as refind doesn’t support the third party drivers.

Used the support flair as it didn’t fit any of the others. Not expecting dedicated support but just dropping the question in one of the few communities I’m likely to find someone else who has stacked the same pile of niches I’m trying to onto each other.

Very much aware of the fact that I’m going outside the supported parameters of all 3 pieces I’m trying to combine here and arch is the least relevant of the 3, but alas refind don’t have a subreddit, and the ZFS one is more concerned with pool management than boot management.

2 points

ZFS UEFI drivers have never worked for me with rEFInd, while loading kernels/initramfs's from FAT32 (standard for ESP) has worked on everything I tried from old Atoms to the latest EPYCs.

It may be because of the feature flags enabled in your boot pool which the driver doesn't support. If you want a config that always works I'd recommend just putting the boot files in the ESP. The archzfs initcpio hook handles using an encrypted dataset as the rootfs.

3 points

Boot is in grub2 compatibility mode, but I feel like this is probably the case and refind is just missing some piece of knowledge it would need to mount or search a ZFS dataset.

I’ve got plenty of space to put boot on the esp, and it works, I’ve tried it. I just wanted to push at the edge of the problem a bit before falling back on that.

Outside of easy rollback if I break my init or kernal there’s I’m not losing much by not having boot on ZFS. I’d just like to learn a bit about the problem before moving on.

1 points

I do zfs root with crypto and /boot on ext using systemd-boot. You can put your kernel and initrd on esp if you want. You don’t need a /boot volume but you’d have to setup your own hooks to copy kernel and initrd to the esp. I haven’t used rEFInd in a decade. Does it support encrypted zfs?

2 points

I’m still not even sure (other than one account I’ve found and implication in the refind manual) that refind even supports unencrypted zfs. But I haven’t encrypted my boot dataset, door is encrypted but that’s handled init.

Moving kernel and init to the ESP is my next step (and works just fine) I just wanted to explore the problem a bit before going with that.

1 points

Just don't. If you want to use ZFS and not go insane with boot configuration, just go for FAT32 or ext4 /boot. Assuming you have EFI, you could try go for systemd-boot, if you need multi-boot-configuration. Even on rodsbooks website, the guy suggests to use /boot as ESP for rEFInd.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.