You are not logged in.

#1 2020-10-22 23:18:24

armoredkitten
Member
Registered: 2019-10-31
Posts: 15

[SOLVED] rEFInd with btrfs root giving invalid loader error

Hi there, I'm trying to install Arch on a new machine and figured I'd try out a few changes from my previous install. I have / set up on btrfs, but have separate /boot and /efi partitions that are ext4 and vfat, respectively. (I'm dual booting with Windows, so I wanted to try to avoid issues with the ESP directory being too small.)

The install seemed to go successfully, but when booting through rEFInd, I get an error about the loader file being invalid.

# lsblk -f
NAME        FSTYPE   FSVER            LABEL       UUID                                 FSAVAIL FSUSE% MOUNTPOINT
loop0       squashfs 4.0                                                                     0   100% /run/archiso/sfs/airootfs
sda                                                                                                   
├─sda1      ntfs                      WinHome     3C7A729F7A72561C                                    
└─sda2      btrfs                     LinuxHome   b3cdd75a-efa1-430f-a9e3-634245823229                
sdb         iso9660  Joliet Extension ARCH_202010 2020-10-22-16-45-28-00                              
├─sdb1      iso9660  Joliet Extension ARCH_202010 2020-10-22-16-45-28-00                     0   100% /run/archiso/bootmnt
└─sdb2      vfat     FAT16            ARCHISO_EFI 7D7A-1DB6                                           
nvme0n1                                                                                               
├─nvme0n1p1 vfat     FAT32                        F278-9ACF                                           
├─nvme0n1p2                                                                                           
├─nvme0n1p3 ntfs                                  584289E24289C56A                                    
├─nvme0n1p4 ntfs                                  EC145B5B145B283A                                    
├─nvme0n1p5 ext4     1.0              LinuxBoot   2d2c20ec-afe1-4838-9980-e13b1ea91fe3                
├─nvme0n1p6 swap     1                swap        cf507361-60f3-489b-9056-e5178bd072e1                
├─nvme0n1p7 btrfs                     LinuxRoot   d0b55a6e-a73f-458f-ad77-32574c11c92c                
└─nvme0n1p8 ext4     1.0              LinuxPlay   0f90d4e8-4e36-4357-94f8-9a0a4dc8d576                

/dev/nvme0n1p1 is my /efi, /dev/nvme0n1p5 is /boot, and /dev/nvme0n1p7 is my btrfs / partition, as you can see below:

# cat /mnt/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/nvme0n1p7 LABEL=LinuxRoot
UUID=d0b55a6e-a73f-458f-ad77-32574c11c92c	/         	btrfs     	rw,relatime,ssd,space_cache,subvolid=258,ubvol=root	0 0

# /dev/nvme0n1p1
UUID=F278-9ACF      				/efi      	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/nvme0n1p5 LABEL=LinuxBoot
UUID=2d2c20ec-afe1-4838-9980-e13b1ea91fe3	/boot     	ext4      	rw,relatime	0 2

# /dev/sda2 LABEL=LinuxHome
UUID=b3cdd75a-efa1-430f-a9e3-634245823229	/home     	btrfs     	rw,relatime,space_cache,subvolid=260,subvol=home	0 0

# /dev/sda2 LABEL=LinuxHome
UUID=b3cdd75a-efa1-430f-a9e3-634245823229	/var      	btrfs     	rw,relatime,space_cache,subvolid=261,subvol=var	0 0

# /dev/nvme0n1p6 LABEL=swap
UUID=cf507361-60f3-489b-9056-e5178bd072e1	none      	swap      	defaults  	0 0

Here's what's in my refind.conf, with everything set to defaults except for this entry at the bottom:

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=d0b55a6e-a73f-458f-ad77-32574c11c92c rw add_efi_memmap rootflags=subvol=root"
    submenuentry "Boot using fallback initramfs" {
        initrd /boot/initramfs-linux-fallback.img
    }
    submenuentry "Boot to terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}
# cat /mnt/boot/refind_linux.conf
"Boot with standard options"  "root=PARTUUID=d0b55a6e-a73f-458f-ad77-32574c11c92c rw rootflags=subvol=root initrd=root\boot\initramfs-%v.img"
"Boot to single-user mode"  "root=PARTUUID=d0b55a6e-a73f-458f-ad77-32574c11c92c rw rootflags=subvol=root initrd=root\boot\initramfs-%v.img single"
"Boot with minimal options"  "ro root=PARTUUID=d0b55a6e-a73f-458f-ad77-32574c11c92c rw rootflags=subvol=root initrd=root\boot\initramfs-%v.img single"

I'm honestly not sure about any of this, and what's confusing things for me is that my / partition is btrfs but my /boot partition is not. Does that mean I need to specify the subvolume everywhere as the wiki page suggests? That's not particularly clear to me.

Any help would be much appreciated!

Last edited by armoredkitten (2020-10-23 20:54:14)

Offline

#2 2020-10-23 01:52:51

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: [SOLVED] rEFInd with btrfs root giving invalid loader error

volume   "Arch Linux"

Yet you don't seem to have a volume by that name?

Your loader and initrd paths are likely wrong, too. Remember, they're relative to that volume, not your root.

Last edited by Scimmia (2020-10-23 01:55:10)

Offline

#3 2020-10-23 03:07:15

romstor
Member
Registered: 2018-08-18
Posts: 54

Re: [SOLVED] rEFInd with btrfs root giving invalid loader error

Also in the first line in fstab you have a type "ubvol=root" - should be "subvol=root". That is not a problem though as kernel mounts root partition taken from "rootflags" command line.

I think you have confused "small efi partition instructions for systemd-boot" (https://wiki.archlinux.org/index.php/Sy … g_XBOOTLDR) that can look for kernels on another partition and how you'd do the same in rEFInd (https://wiki.archlinux.org/index.php/RE … stallation) which doesn't need that.

rEFInd boot loader is very small - and this is the only thing you need to put on existing EFI partition. It is not going to grow with more kernels over time. Because rEFInd understands btrfs - you can just point to your kernel on btrfs (i.e. your /boot will be right on btrfs root subvolume).

May be there is a way to give rEFInd instructions to look for kernel in a different place from the booting system root, but I am not that proficient with rEFInd to advise further.

TL;DR: I don't think you need ext4 boot partition at all.

Does that mean I need to specify the subvolume everywhere as the wiki page suggests? That's not particularly clear to me.

Your boot is not on btrfs root at all - thats why specifying it doesn't work. It is a separate ext4 partition (that i think you don't need). Put boot dir on root subvolume, rerun mkinitcpio and make sure the kernel is actually there and you'll boot.

Remember that fstab mounts happen after kernel is booted, so you can't reference it in your parameters unless rEFInd supports  explicitly specifying different partition for kernel.

EDIT: Your "volume" should point to your /boot ext4 partition: https://www.rodsbooks.com/refind/config … ml#stanzas

And it should work as it is.

Last edited by romstor (2020-10-23 03:44:33)

Offline

#4 2020-10-23 20:53:47

armoredkitten
Member
Registered: 2019-10-31
Posts: 15

Re: [SOLVED] rEFInd with btrfs root giving invalid loader error

Thanks for your help, both of you.

@romstor: It wasn't in fact that I was confused about the "small efi partition" -- I'm aware that the bulk of the size is going to be in /boot rather than in the EFI partition. It's primarily that I figured I'd just leave the partition that Windows created for the EFI, since it can sometimes end up being too small to fit the whole /boot in there. /efi just ends up having /efi/EFI inside it, and that's fine with me.

And yes, my initial reasoning for separating out /boot into its own partition was for "simplicity" (keeping it as ext4 rather than trying to use btrfs, although I know the kernel supports it), but maybe in retrospect it's caused more issues than it was worth. But I'm stubborn and want to make it work my way, dammit! (Seriously, though, your point is taken that putting /boot in with the same btrfs root partition is totally a reasonable option.)

@Scimmia, that was the main problem -- I had looked at the example from the wiki which had "Arch Linux" as the volume name, and didn't pay close enough attention that it needed to be changed. I also had issues because I made a dumb assumption that PARTUUID == UUID, which it turns out....it does not. I ended up just changing to PARTLABEL (both for referring to the volume, and for passing the root partition to the kernel), which worked just fine.

My updated refind.conf menu entry is as follows:

menuentry "Arch Linux" {
    icon     /EFI/refind/icons/os_arch.png
    volume   "LinuxBoot"
    loader   /vmlinuz-linux
    initrd   /initramfs-linux.img
    options  "root=PARTLABEL=LinuxRoot rw add_efi_memmap rootflags=subvol=root"
    submenuentry "Boot using fallback initramfs" {
        initrd /initramfs-linux-fallback.img
    }
    submenuentry "Boot to terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}

Thanks again! I will mark this as solved.

Offline

#5 2020-10-24 19:02:49

romstor
Member
Registered: 2018-08-18
Posts: 54

Re: [SOLVED] rEFInd with btrfs root giving invalid loader error

armoredkitten wrote:

And yes, my initial reasoning for separating out /boot into its own partition was for "simplicity" (keeping it as ext4 rather than trying to use btrfs, although I know the kernel supports it), but maybe in retrospect it's caused more issues than it was worth. But I'm stubborn and want to make it work my way, dammit! (Seriously, though, your point is taken that putting /boot in with the same btrfs root partition is totally a reasonable option.)

Congrats on figuring this out. Note that it is the bootloader support for btrfs that is important here - kernel hasn't booted yet :-). For the future, if you decide to boot from different snapshots - keep in mind that on kernel update you'll get the new kernel for _all_ the snapshots. It is usually not a big issue if you never boot into them being far apart. I usually run a bunch of "test" snapshots and they can get old and I don't want the main kernel to be updated as I play with different configurations. That is why in your scenario having /boot on btrfs solves the problem.

But if you insist (and in case you use something like systemd-boot, which can't use kernel on btrfs) on having a separate /boot partition, you can still get away with booting into different snapshots (located on large /efi or separate ext4 /boot) via bindmounts. See this article for more info:

Multi Boot Linux With One Boot Partition | John Ramsden

Good luck. Arch is strong with this one.

Offline

Board footer

Powered by FluxBB