Venom1991 / refind-btrfs

Generate rEFInd manual boot stanzas from Btrfs snapshots
GNU General Public License v3.0
144 stars 8 forks source link

Help with manual boot stanza #17

Open wazlecracker opened 2 years ago

wazlecracker commented 2 years ago

Hello!

I'm on Arch and have installed your tool and can successfully run refind-btrfs, however I can't seem to get the manual boot stanza correct to boot into my system. I can boot into it with the default entry rEFInd generates with its (I think) scanning, but trying to boot the manual entry fails with "invalid loader file!" and I'm not sure what I'm doing wrong.

Stanza:

menuentry "Arch Linux" {
    icon /EFI/refind/icons/os_arch.png
    volume Arch #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"
    }
}

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

Can you help me figure out what I'm doing wrong here?

Venom1991 commented 2 years ago

Hi,

I'm going to have to see your generated boot stanza. Also, paste the writable snapshot's (should be located in /root/.refind-btrfs) fstab file here, as well.

Do you still have the auto-generated refind_linux.conf file located in /boot? If so, try deleting it. That one might cause issues, as well.

wazlecracker commented 2 years ago

I'm not sure what you mean by generated boot stanza if it's not what I put above.

Here's the fstab of the latest snapshot:

# 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=388,subvol=/@root/.refind-btrfs/rwsnap_2021-09-18_13-00-01_ID387  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

I do not have a refind_linux.conf.

I saw another comment about getting rid of the commented out partuuid after volume but don't see it now. I deleted that and still the same results.

Venom1991 commented 2 years ago

There should be a generated boot stanza (defined in a generated config file) located in the "btrfs-snapshot-stanzas" directory which is itself located in the rEFInd's root directory. What you've pasted is your own boot stanza which you've defined directly in the refind.conf file, i.e. the source boot stanza.
I'm assuming here that you did not change the "modify_read_only_flag" option by setting it to true.

The fstab file that you've pasted here appears to be correct.

I've deleted that comment because it turned out not to be true because the comments are completely ignored while parsing (which is good).

wazlecracker commented 2 years ago

Oh sorry! Now I understand. Here it is:

cat arch_vmlinuz-linux.conf 
menuentry "Arch Linux (rwsnap_2021-09-18_13-00-01_ID387)" {
icon /EFI/refind/icons/os_arch.png
volume Arch
loader /@root/.refind-btrfs/rwsnap_2021-09-18_13-00-01_ID387/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-18_13-00-01_ID387/boot/initramfs-linux.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-18_13-00-01_ID387 initrd=@root\.refind-btrfs\rwsnap_2021-09-18_13-00-01_ID387\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf"
submenuentry "Boot - fallback (rwsnap_2021-09-18_13-00-01_ID387)" {
initrd /@root/.refind-btrfs/rwsnap_2021-09-18_13-00-01_ID387/boot/initramfs-linux-fallback.img
}
submenuentry "Boot - terminal (rwsnap_2021-09-18_13-00-01_ID387)" {
add_options "systemd.unit=multi-user.target"
}
submenuentry "Arch Linux (rwsnap_2021-09-17_21-00-00_ID384)" {
loader /@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384/boot/initramfs-linux.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384 initrd=@root\.refind-btrfs\rwsnap_2021-09-17_21-00-00_ID384\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf"
}
submenuentry "Boot - fallback (rwsnap_2021-09-17_21-00-00_ID384)" {
loader /@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384/boot/initramfs-linux-fallback.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384 initrd=@root\.refind-btrfs\rwsnap_2021-09-17_21-00-00_ID384\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf"
}
submenuentry "Boot - terminal (rwsnap_2021-09-17_21-00-00_ID384)" {
loader /@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384/boot/initramfs-linux.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-17_21-00-00_ID384 initrd=@root\.refind-btrfs\rwsnap_2021-09-17_21-00-00_ID384\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf systemd.unit=multi-user.target"
}
submenuentry "Arch Linux (rwsnap_2021-09-17_20-42-22_ID380)" {
loader /@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380/boot/initramfs-linux.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380 initrd=@root\.refind-btrfs\rwsnap_2021-09-17_20-42-22_ID380\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf"
}
submenuentry "Boot - fallback (rwsnap_2021-09-17_20-42-22_ID380)" {
loader /@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380/boot/initramfs-linux-fallback.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380 initrd=@root\.refind-btrfs\rwsnap_2021-09-17_20-42-22_ID380\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf"
}
submenuentry "Boot - terminal (rwsnap_2021-09-17_20-42-22_ID380)" {
loader /@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380/boot/vmlinuz-linux
initrd /@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380/boot/initramfs-linux.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw add_efi_memmap rootflags=subvol=@root/.refind-btrfs/rwsnap_2021-09-17_20-42-22_ID380 initrd=@root\.refind-btrfs\rwsnap_2021-09-17_20-42-22_ID380\boot\amd-ucode.img nowatchdog video=DP-1:2560x1440@144 video=DP-2:2560x1440@144 lsm=lockdown,yama,apparmor,bpf systemd.unit=multi-user.target"
}
}
wazlecracker commented 2 years ago

Also, the relevant section from my refind-btrfs.conf:

[snapshot-manipulation]
selection_count = 3
modify_read_only_flag = false
destination_dir = "/root/.refind-btrfs"
cleanup_exclusion = []
Venom1991 commented 2 years ago

Try checking whether the loader and initrd files actually exist in the /root/.refind-btrfs/rwsnap_2021-09-18_13-00-01_ID387/boot directory. These files are: vmlinuz-linux, initramfs-linux.img and amd-ucode.img. Their existence (within the writable snapshot, after it's been created) is validated by refind-btrfs but check them manually as well, just to be sure.

Also, it's pretty weird seeing this part being present in the "options" field - "video=DP-1:2560x1440@144 video=DP-2:2560x1440@144", considering that it doesn't exist in the source boot stanza.

Other than that, I don't really have an idea as to what exactly went wrong.

wazlecracker commented 2 years ago

They do exist there as well.

I threw that in the options because there's some funkiness going on with a RX 5700XT and 2 monitors and it resolved the issue for me with GRUB. Was testing whether or not I still need it.

Venom1991 commented 2 years ago

Well, I don't really have an idea in that case - my setup is very, very similar to yours (Intel instead of AMD and a somewhat different subvolume setup) and I'm able to boot into snapshots just fine.
Did you see this?

wazlecracker commented 2 years ago

Managed to get it to boot. But I have no idea why this worked lol.

Changed my stanza to this:

menuentry "Arch Linux" {
icon /EFI/refind/icons/os_arch.png
volume Arch
loader /boot/vmlinuz-linux
initrd /boot/initramfs-linux.img
options "root=PARTUUID=e2f8e8fb-74be-154a-ba21-a59938903cbc rw 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"
}
}

I checked the boot options of the entry that worked and saw that it had initrd=boot\initramfs-linux.img so applied that logic to my manual stanza.

Venom1991 commented 2 years ago

And how does a generated stanza look like after these changes?

wazlecracker commented 2 years ago

Well, when I run refind-btrfs, I get this error:

refind-btrfs
Initializing the block devices using lsblk.
Initializing the physical partition table for device '/dev/sda' using lsblk.
Initializing the live partition table for device '/dev/sda' using findmnt.
Initializing the physical partition table for device '/dev/sdb' using lsblk.
Initializing the live partition table for device '/dev/sdb' using findmnt.
Initializing the physical partition table for device '/dev/sdc' using lsblk.
Initializing the live partition table for device '/dev/sdc' using findmnt.
Initializing the physical partition table for device '/dev/sdd' using lsblk.
Initializing the live partition table for device '/dev/sdd' using findmnt.
Initializing the physical partition table for device '/dev/sde' using lsblk.
Initializing the live partition table for device '/dev/sde' using findmnt.
Initializing the physical partition table for device '/dev/nvme0n1' using lsblk.
Initializing the live partition table for device '/dev/nvme0n1' using findmnt.
Initializing the physical partition table for device '/dev/nvme1n1' using lsblk.
Initializing the live partition table for device '/dev/nvme1n1' using findmnt.
Found the ESP mounted at '/boot/efi' on '/dev/nvme1n1p1'.
Found the root partition on '/dev/nvme1n1p2'.
Searching for snapshots of the '@' subvolume in the '/.snapshots' directory.
Found subvolume '@' mounted as the root partition.
Found 59 snapshots of the '@' subvolume.
Searching for the 'refind.conf' file on '/dev/nvme1n1p1'.
Analyzing the 'refind.conf' file.
Found 1 boot stanza matched with the root partition.
WARNING: Detected boot files required by the 'Arch Linux' boot stanza which are not matched with the '@' subvolume: /boot/initramfs-linux.img, /boot/vmlinuz-linux, boot/amd-ucode.img!
ERROR (refind_btrfs.state_management.conditions/conditions.py/check_matched_boot_stanzas): None of the matched boot stanzas are usable!

I'm wondering if there's something more fundamentally wrong with my install.

Venom1991 commented 2 years ago

That is expected since you've removed the root subvolume's prefix from the paths themselves ("@").
What you can try, though, is setting the "include_paths" option to false which will then result in the generated boot stanza having the same loader and initrd paths as the original boot stanza. This isn't ideal because you'll then effectively always be booting into the latest kernel (same as having a separate /boot partition) but it's worth a try, at least.

I really don't see what might be wrong with your setup, it looks just fine to me.

I've downloaded rEFInd's source (version 0.13.2) just to see whether I can find exactly what can cause the error you've been receiving. It's kinda cryptic, though:

IsValid = !EFI_ERROR(Status) &&
        Size == sizeof(Header) &&
        ((Header[0] == 'M' && Header[1] == 'Z' &&
        (Size = *(UINT32 *)&Header[0x3c]) < 0x180 &&
        Header[Size] == 'P' && Header[Size+1] == 'E' &&
        Header[Size+2] == 0 && Header[Size+3] == 0 &&
        *(UINT16 *)&Header[Size+4] == EFI_STUB_ARCH) ||
        (*(UINT32 *)&Header == FAT_ARCH));

These conditions result in false being set to the "IsValid" variable, in your case. Why? Honestly, I have no idea because that snippet is indecipherable to me.
Maybe you could try asking for help here? The author usually responds within a day or two.
I'd also be interested to know why it is that a loader path pointing to a nested subvolume (snapshots are subvolumes, essentially) results in the "IsValid" variable being set to false.

IngwiePhoenix commented 2 years ago

Hello!

I am having the exact same problem - but, I can not even boot into the manual stanza created initially for the refind-btrfs tool to pick up...

First, my setup is this: I use a PCIe NVMe for my main OS, Windows, and it also has the ESP I use all the time for everything. I installed Garuda on a SATA SSD (seen as /dev/sdb) and modified fstab to actually include the proper, correct ESP. This is prune to leave me with GRUB errors eventually but I'll find a way for that, too.

Anyway, since I use rEFInd for booting, I wrote this:

menuentry "Garuda Linux" {
    icon /EFI/refind/icons/os_arch.png
    volume 80e2c3af-3e9e-4322-8695-6127ab3f330e
    loader /@/boot/vmlinuz-linux-mainline
    initrd /@/boot/initramfs-linux-mainline.img
    options "root=UUID=80e2c3af-3e9e-4322-8695-6127ab3f330e rw rootflags=subvol=@ quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0 systemd.unified_cgroup_hierarchy=1 loglevel=3"
    submenuentry "Boot - Zen" {
        loader /@/boot/vmlinuz-linux-zen
    }
    submenuentry "Boot - Zen fallback" {
        loader /@/boot/vmlinuz-linux-zen
        initrd /@/boot/initramfs-linux-zen.img
    }
    submenuentry "Boot - fallback" {
        initrd /@/boot/initramfs-linux-mainline-fallback.img
    }
    submenuentry "Boot - terminal" {
        add_options "systemd.unit=multi-user.target"
    }
}

Since I am experimenting with Linux modules, I also added entries for the mainline kernel alongside zen.

But although this should be all correct, I still get "Invalid Loader!" errors, on all four configurations.

Using the btrfs driver for Windows, I can confirm that the loader and images are there:

PS H:\@\boot> dir

    Verzeichnis: H:\@\boot

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
da----        16.12.2021     20:42                efi
da----        29.11.2021     21:54                memtest86+
da----        16.12.2021     21:20                grub
-a----        02.11.2021     19:41          51200 amd-ucode.img
-a----        16.12.2021     20:53       11184864 vmlinuz-linux-zen
-a----        16.12.2021     20:53       40770980 initramfs-linux-zen.img
-a----        16.12.2021     20:53       66808320 initramfs-linux-zen-fallback.img
-a----        16.12.2021     21:03       10513728 vmlinuz-linux-mainline
-a----        16.12.2021     21:03       40583390 initramfs-linux-mainline.img
-a----        16.12.2021     21:03       67300424 initramfs-linux-mainline-fallback.img

Did I overlook something in the stanza? I am feeling a little confused :)

Thank you in advance!

Venom1991 commented 2 years ago

@IngwiePhoenix

Hi there,

you might want to split the linux-mainline and linux-zen into two boot stanzas because I don't think that the "Boot - Zen" sub-menu entry could ever work correctly due to the mismatch between its "loader" option and the main "initrd" option which it inherits.
Other than that, I don't see anything inherently wrong with your boot stanza and I really don't know why would rEFInd claim that your loader ("/@/boot/vmlinuz-linux-mainline") is invalid.

All I can do is offer you the same advice that I've offered to @wazlecracker, that is to try asking this question in rEFInd's official discussion page. Why? Well, simply because its author and maintainer, Rod Smith, is active there and he is more far more likely to help you than I am.

mbana commented 7 months ago

Not 100% sure this will work just yet. I will confirm if it does.

I think I ran into a similar issue. Here is a portion of my /boot/efi/EFI/refind/refind.conf:

menuentry "Fedora Linux 39 (Workstation Edition)" {
    icon /EFI/refind/icons/os_fedora.png
    volume "fedora-rootfs"
    initrd \@\boot\initramfs.img
    loader \@\boot\vmlinuz
    options "root=UUID=5d302ebd-64a4-4d17-834b-61bd9e1d4cb2 rootflags=subvol=@ ro sysrq_always_enabled=1 add_efi_memmap mitigations=off rd.loglevel=0 systemd.show_status=false rd.udev.log-priority=0 udev.log-priority=0 quiet net.ifnames=0"
}

Then when I run:

$ sudo rm -fvr /var/lib/refind-btrfs/local_db && sudo refind-btrfs --run-mode one-time
removed '/var/lib/refind-btrfs/local_db'
Initializing the block devices using lsblk.
Initializing the physical partition table for device '/dev/zram0' using lsblk.
Analyzing the 'refind-btrfs.conf' file.
Initializing the live partition table for device '/dev/zram0' using findmnt.
Initializing the physical partition table for device '/dev/nvme1n1' using lsblk.
Initializing the live partition table for device '/dev/nvme1n1' using findmnt.
Initializing the physical partition table for device '/dev/nvme0n1' using lsblk.
Initializing the live partition table for device '/dev/nvme0n1' using findmnt.
Found the ESP mounted at '/boot/efi' on '/dev/nvme1n1p1'.
Found the root partition on '/dev/nvme1n1p2'.
Searching for snapshots of the '@' subvolume in the '/.snapshots' directory.
Found subvolume '@' mounted as the root partition.
Found 3 snapshots of the '@' subvolume.
Searching for the 'refind.conf' file on '/dev/nvme1n1p1'.
Analyzing the 'refind.conf' file.
Found 1 boot stanza matched with the root partition.
Getting all snapshots in the '/root/.refind-btrfs' directory.
Initializing the static partition table for subvolume '@snapshots/3/snapshot' from its fstab file.
Initializing the static partition table for subvolume '@snapshots/2/snapshot' from its fstab file.
Initializing the static partition table for subvolume '@snapshots/1/snapshot' from its fstab file.
Found 3 snapshots for addition.
Creating a new writable snapshot from the read-only '@snapshots/3/snapshot' snapshot at '/root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284'.
WARNING: The '/root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284' directory is already a subvolume.
Modifying the '/root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284/etc/fstab' file.
Creating a new writable snapshot from the read-only '@snapshots/2/snapshot' snapshot at '/root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280'.
WARNING: The '/root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280' directory is already a subvolume.
Modifying the '/root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280/etc/fstab' file.
Creating a new writable snapshot from the read-only '@snapshots/1/snapshot' snapshot at '/root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279'.
WARNING: The '/root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279' directory is already a subvolume.
Modifying the '/root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279/etc/fstab' file.
Writing to the 'btrfs-snapshot-stanzas/fedora-rootfs_vmlinuz.conf' file.
Appending 1 'include' directive to the 'refind.conf' file.

My /boot/efi/EFI/refind/btrfs-snapshot-stanzas/fedora-rootfs_vmlinuz.conf looks like:

menuentry "Fedora Linux 39 (Workstation Edition) (rwsnap_2023-12-26_20-45-48_ID284)" {
    icon /EFI/refind/icons/os_fedora.png
    volume "fedora-rootfs"
    loader /@/root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284/boot/vmlinuz
    initrd /@/root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284/boot/initramfs.img
    options "root=UUID=5d302ebd-64a4-4d17-834b-61bd9e1d4cb2 rootflags=subvol=@/root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284 ro sysrq_always_enabled=1 add_efi_memmap mitigations=off rd.loglevel=0 systemd.show_status=false rd.udev.log-priority=0 udev.log-priority=0 quiet net.ifnames=0"
    submenuentry "Fedora Linux 39 (Workstation Edition) (rwsnap_2023-12-26_20-13-20_ID280)" {
        loader /@/root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280/boot/vmlinuz
        initrd /@/root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280/boot/initramfs.img
        options "root=UUID=5d302ebd-64a4-4d17-834b-61bd9e1d4cb2 rootflags=subvol=@/root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280 ro sysrq_always_enabled=1 add_efi_memmap mitigations=off rd.loglevel=0 systemd.show_status=false rd.udev.log-priority=0 udev.log-priority=0 quiet net.ifnames=0"
    }
    submenuentry "Fedora Linux 39 (Workstation Edition) (rwsnap_2023-12-26_20-12-36_ID279)" {
        loader /@/root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279/boot/vmlinuz
        initrd /@/root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279/boot/initramfs.img
        options "root=UUID=5d302ebd-64a4-4d17-834b-61bd9e1d4cb2 rootflags=subvol=@/root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279 ro sysrq_always_enabled=1 add_efi_memmap mitigations=off rd.loglevel=0 systemd.show_status=false rd.udev.log-priority=0 udev.log-priority=0 quiet net.ifnames=0"
    }
}

Subvolumes:

sudo btrfs subvolume list -pgqt /                                                   
ID  gen parent  top level   parent_uuid path    
--  --- ------  ---------   ----------- ----    
256 5691    5   5       -                                       @home
258 5691    5   5       -                                       @
259 5639    258 258     -                                       var/lib/machines
262 5680    5   5       -                                       @snapshots
279 5667    262 262     a308b1a1-b187-114d-8c74-480010bb630f    @snapshots/1/snapshot
280 5666    262 262     a308b1a1-b187-114d-8c74-480010bb630f    @snapshots/2/snapshot
282 5691    258 258     5ff80d6e-32d6-154c-878f-b2533c1df715    root/.refind-btrfs/rwsnap_2023-12-26_20-13-20_ID280
283 5691    258 258     191ef6ff-6756-fa43-8f05-a21c1c5b980d    root/.refind-btrfs/rwsnap_2023-12-26_20-12-36_ID279
284 5681    262 262     a308b1a1-b187-114d-8c74-480010bb630f    @snapshots/3/snapshot
285 5691    258 258     698beec4-bd50-d74b-abc7-f34c2ece6421    root/.refind-btrfs/rwsnap_2023-12-26_20-45-48_ID284

/etc/refind-btrfs.conf

NB: I've modified it so that it's include_paths = false.

...
[boot-stanza-generation]
refind_config = "refind.conf"
include_paths = false
include_sub_menus = true
source_exclusion = []
...

Otherwise, like you mentioned one cannot boot into the snapshot.


I begin to wonder what @Venom1991's exact setup is like.

Venom1991 commented 7 months ago

@mbana

My setup is almost exactly the same as the one described in the example. The sole difference of note is the fact that I've isolated the /root/.refind-btrfs directory as a subvolume of its own, named @refind-btrfs. That's about it.

You could try setting this option to "true" and observing what happens with regards to the inability to boot into a snapshot. This way, no new writable snapshots will be created from the read-only ones created by, presumably, Snapper.

EDIT: You're using Fedora, if I'm not mistaken? It is fairly obvious but I'm not sure if its derivatives exist so it's a fair question (from my perspective, at least). If so, there also exists a discrepancy between rEFInd's version as offered by official Arch and Fedora repositories. It appears that version available for Fedora is 0.13.3.1 (fairly outdated by now, released over a year ago) whereas version 0.14.0.2 is available for Arch.