BTRFS + rEFInd troubles

I’m trying to rebuild my system for learning and other issues I can’t seem to fix.

I’m taking ideas from this person’s github and have a bootable system and I’m using refind-btrfs to give me access to my snapshots in rEFInd as well… however I can’t seem to get rEFInd to do what I want.

I know my manual stanza in refind.conf isn’t correct, but I don’t know exactly what the issue is. rEFInd will boot into my install, but it fails to do anything when I pick the entry that represents my stanza.

My fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/         	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=256,subvol=/@	0 0

# /dev/nvme1n1p1
UUID=46D6-555C								/boot/efi 	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/home     	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=257,subvol=/@home	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/root     	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=258,subvol=/@root	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/log  	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=259,subvol=/@var-log	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/.swap    	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=260,subvol=/@swap	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/crash	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=261,subvol=/@var-crash	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/spool	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=262,subvol=/@var-spool	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/lib/docker	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=263,subvol=/@var-lib-docker	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/lib/containers	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=264,subvol=/@var-lib-containers	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/tmp  	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=265,subvol=/@var-tmp	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/cache	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=266,subvol=/@var-cache	0 0

# /dev/nvme1n1p2 LABEL=Arch
UUID=7733104b-3bd5-40fa-916f-bd2e30645e52	/var/lib/libvirt/images	btrfs     	rw,noatime,compress=zstd:3,ssd,discard=async,space_cache,subvolid=267,subvol=/@var-lib-libvirt-images	0 0


/.swap/swapfile	none	swap	defaults	0	0

/dev/zram0	none	swap	defaults	0	0

Manual boot stanza:

menuentry "EOS" {
    icon /EFI/refind/icons/os_arch.png
    volume 7733104b-3bd5-40fa-916f-bd2e30645e52
    loader /@/boot/vmlinuz-linux
    initrd /@/boot/initramfs-linux.img
    options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@ nowatchdog lsm=lockdown,yama,apparmor,bpf"
    submenuentry "Boot - fallback" {
        initrd /@/boot/initramfs-linux-fallback.img
    }
    submenuentry "Boot - terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}

I suspect I’m not doing the loader or initrd entries correctly with my subvolumes. Can someone help me understand what I’m doing wrong?

I am not a refind guy but I think the issue may be this:

According to the documentation, that should be a partuuid, not a uuid.

Try using e2f8e8fb-74be-154a-ba21-a59938903cbc instead.

EDIT: According to the Arch wiki the partuuid needs to be uppercase.

Ah thanks, missed that part after the example stanza along with the requirement it be in all caps. Let’s see if that’s enough!

1 Like

Unfortunately not :cry:

When I hit enter on the entry in rEFInd, the screen flashes black for an instant and pops right back up to the rEFInd menu.

What does it look like now?

menuentry "EOS" {
    icon /EFI/refind/icons/os_arch.png
    volume E2F8E8FB-74BE-154A-BA21-A59938903CBC
    loader /@/boot/vmlinuz-linux
    initrd /@/boot/initramfs-linux.img
    options "root=PARTUUID=E2F8E8FB-74BE-154A-BA21-A59938903CBC rw add_efi_memmap rootflags=subvol=@ nowatchdog lsm=lockdown,yama,apparmor,bpf"
    submenuentry "Boot - fallback" {
        initrd /@/boot/initramfs-linux-fallback.img
    }
    submenuentry "Boot - terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}

I couldn’t find if the PARTUUID should be all caps in the options too, so I did it as well.

You verified that the partuuid is correct and points to the correct partition?

Also, you aren’t loading any ucode, is that deliberate?

Lastly, you are using the “linux” kernel, correct?

Yes!
nvme1n1p1 is my VFAT and nvme1n1p2 is my root.

ls -al /dev/disk/by-partuuid/
total 0
drwxr-xr-x 2 root root 280 Sep 18 18:38 .
drwxr-xr-x 8 root root 160 Sep 18 18:38 ..
lrwxrwxrwx 1 root root  15 Sep 18 18:38 a3ab5ed4-82f5-0144-a0e4-649c53b24fc2 -> ../../nvme1n1p1
lrwxrwxrwx 1 root root  15 Sep 18 18:38 e2f8e8fb-74be-154a-ba21-a59938903cbc -> ../../nvme1n1p2

You know… I had that in there before and took it out in my troubleshooting. This is what I had before:

menuentry "EOS" {
    icon /EFI/refind/icons/os_arch.png
    volume E2F8E8FB-74BE-154A-BA21-A59938903CBC
    loader /@/boot/vmlinuz-linux
    initrd /@/boot/initramfs-linux.img
    options "root=PARTUUID=E2F8E8FB-74BE-154A-BA21-A59938903CBC rw add_efi_memmap rootflags=subvol=@ initrd=\@\boot\amd-ucode.img nowatchdog lsm=lockdown,yama,apparmor,bpf"
    submenuentry "Boot - fallback" {
        initrd /@/boot/initramfs-linux-fallback.img
    }
    submenuentry "Boot - terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}

That’s correct. It’s currently the only kernel installed there.

Probably should be initrd=boot\amd-ucode.img

I’ll give that a go, wasn’t sure about how BTRFS might affect that.

I am not positive either. It is also possible it should be initrd=@\boot\amd-ucode.img but it seems like it would be relative to the root.

Did you check this as well? This is from the arch wiki:

Tip: make sure btrfs_x64.efi driver is installed, it can be installed manually by copying from /usr/share/refind/drivers_x64/btrfs_x64.efi to esp/EFI/refind/drivers_x64/btrfs_x64.efi, or you can install all drivers with the refind-install /dev/sdx --alldrivers option.

No dice with that way either. It makes me think my loader & initrd entries are wrong. But they look to conform to the wiki example.

I have the BTRFS driver in the right place for sure.

You appear to be headed down the right road - but there are more ways than one to get there…

To get the ucode in there you need to specify it on its own line above the existing initrd line - but I can’t find the reference for it right now - so…

Another way to get where you’re going is to allow rEFInd to operate from the GRUB2 entry, as that will take into account all the snapshots and other things as they occur (don’t use os-prober!). I use this myself on a multi-boot that includes Garuda - allowing Garuda to do its own thing with the Grub entries. Simplifies life quite a bit (does not require custom stanzas for instance), but allows rEFInd to control the initial boot process properly.

More if needed…(examples etc)

I’d appreciate it if you could find that reference.

I’m trying to do this with rEFInd only since refind-btrfs allows for access to snapshots, but has the requirement of a manual boot stanza. I was using GRUB only before, and it certainly was easier with snapshots lol, but I’m at the point where I wanna get this working just to know I did it lol.

The main site for rEFInd is: rodsbooks.com/refind - but a quick look around didn’t find the reference yet. I’ll give it a try. It’s somewhere in the ‘how to build a stanza’ information - but it’s been a couple of years since I read it (and I’m getting old!). Off to try it… :grin:

Not exactly the reference I was looking for, but may apply. This is from the Archwiki…

esp/EFI/refind/refind.conf
...

menuentry "Arch Linux" {
	icon     /EFI/refind/icons/os_arch.png
	volume   "Arch Linux"
	loader   /boot/vmlinuz-linux
	initrd   /boot/initramfs-linux.img
	options  "root=PARTUUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX rw add_efi_memmap initrd=boot\intel-ucode.img initrd=boot\amd-ucode.img"
	submenuentry "Boot using fallback initramfs" {
		initrd /boot/initramfs-linux-fallback.img
	}
	submenuentry "Boot to terminal" {
		add_options "systemd.unit=multi-user.target"
	}
}

Notice that the options are added after the original initrd line, and are built similarly to the refind_linux.conf entries you might have had if a manual stanza was not used. Looks like it might help - or at least let you get the microcode in!

(note carefully the \ instead of / in the options line!)

Yea, I was following that initially and trying to adjust where necessary for BTRFS, but then I also used the refind-btrfs example:

menuentry "Arch Linux - Stable" {
    icon /EFI/refind/icons/os_arch.png
    volume ARCH
    loader /@/boot/vmlinuz-linux
    initrd /@/boot/initramfs-linux.img
    options "root=PARTUUID=048d6fcd-c88c-504d-bd51-dfc0a5bf762d rw add_efi_memmap rootflags=subvol=@ initrd=@\boot\intel-ucode.img"
    submenuentry "Boot - fallback" {
        initrd /@/boot/initramfs-linux-fallback.img
    }
    submenuentry "Boot - terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}

I do get a briefest flash of an error message when I hit enter on the entry for my stanza, but it’s way too fast for me to read.

It seems like I’m missing something fundamental here as it won’t even attempt to load.

Only thing that comes to mind is to try it with \ (starting with the initrd spec only) - and see what that generates. I guess M$ got in there in the UEFI spec talks… and it’s hard to tell where the influence stops!

I finally got a read on the error, it was “Invalid loader file!”

So that would mean my loader /@/boot/vmlinuz-linux line is wrong, correct?

It would seem so. You have made the obvious checks - like the file is there, and under that name? :grin: Perhaps the \ problem there too? Or, does the path start with @ not /@? And various changes on the theme… There is nothing overtly wrong with your stanza that i can recognize…

Sorry my systems are not enough like yours to test for myself - at least until I can get a VM to behave properly!

EDIT: Are you sure you need the @ form of reference - I don’t see it in the Archwiki for btrfs??