Venom1991 / refind-btrfs

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

Error: Could not find a boot stanza matched with the root partition! #54

Closed mstio closed 3 months ago

mstio commented 4 months ago

Hi,

my layout looks like this:

{ "filesystems": [ { "partuuid": "789703e5-4ef9-426d-b9fe-28a7cd45e80f", "partlabel": null, "uuid": "0e7d2631-ad19-41c7-add3-35ffab4bb532", "source": "/dev/nvme0n1p9", "fstype": "btrfs", "label": "linux", "target": "/", "options": "rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/@" },{ "partuuid": "789703e5-4ef9-426d-b9fe-28a7cd45e80f", "partlabel": null, "uuid": "0e7d2631-ad19-41c7-add3-35ffab4bb532", "source": "/dev/nvme0n1p9", "fstype": "btrfs", "label": "linux", "target": "/home", "options": "rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=257,subvol=/@home" },{ "partuuid": "789703e5-4ef9-426d-b9fe-28a7cd45e80f", "partlabel": null, "uuid": "0e7d2631-ad19-41c7-add3-35ffab4bb532", "source": "/dev/nvme0n1p9", "fstype": "btrfs", "label": "linux", "target": "/var/cache", "options": "rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=258,subvol=/@cache" },{ "partuuid": "789703e5-4ef9-426d-b9fe-28a7cd45e80f", "partlabel": null, "uuid": "0e7d2631-ad19-41c7-add3-35ffab4bb532", "source": "/dev/nvme0n1p9", "fstype": "btrfs", "label": "linux", "target": "/var/log", "options": "rw,noatime,compress=zstd:3,ssd,discard=async,space_cache=v2,subvolid=259,subvol=/@log" },{ "partuuid": "801794d3-a44d-408b-a306-b78f46477a49", "partlabel": null, "uuid": "F7DD-989C", "source": "/dev/nvme0n1p7", "fstype": "vfat", "label": "BOOT", "target": "/efi", "options": "rw,relatime,fmask=0137,dmask=0027,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro" },{ "partuuid": null, "partlabel": null, "uuid": null, "source": "portal", "fstype": "fuse.portal", "label": null, "target": "/run/user/1000/doc", "options": "rw,nosuid,nodev,relatime,user_id=1000,group_id=1000" } ] }

But

journalctl -u refind-btrfs -b

says:

Apr 06 19:10:14 man systemd[1]: Starting Generate rEFInd manual boot stanzas from Btrfs snapshots... Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Analyzing the 'refind-btrfs.conf' file. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Scheduling watch for directories: /.snapshots, /.snapshots/13, /.snapshots/14, /.snapshots/15, /.snapshots/16, /.snapshots/17, /.snapshots/18, /.snapshots/19, /.> Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Starting the observer with PID 896. Apr 06 19:10:14 man systemd[1]: Started Generate rEFInd manual boot stanzas from Btrfs snapshots. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: The '/.snapshots/25' snapshot has been created. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Initializing the block devices using lsblk. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Initializing the physical partition table for device '/dev/nvme0n1' using lsblk. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Initializing the live partition table for device '/dev/nvme0n1' using findmnt. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Found the ESP mounted at '/efi' on '/dev/nvme0n1p7'. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Found the root partition on '/dev/nvme0n1p9'. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Searching for snapshots of the '@' subvolume in the '/.snapshots' directory. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Found subvolume '@' mounted as the root partition. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Found 13 snapshots of the '@' subvolume. Apr 06 19:10:14 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: Searching for the 'refind.conf' file on '/dev/nvme0n1p7'. Apr 06 19:10:15 man /usr/lib/python3.11/site-packages/refind_btrfs/main.py[896]: ERROR (refind_btrfs.state_management.conditions/conditions.py/check_matched_boot_stanzas): Could not find a boot stanza matched with the root partition!

In the refind-btrfs.conf I set

esp_uuid = "801794d3-a44d-408b-a306-b78f46477a49" (otherwise refind-btrfs could find it)

and

refind_config = "refind.conf" (just for good measures)

What did I do wrong?

Venom1991 commented 4 months ago

@mstio

Paste your boot stanza here, as well.

mstio commented 4 months ago

sure:

efi/loader/loader.conf:5: Unknown line 'reboot-for-bitlocker', ignoring.
         type: Boot Loader Specification Type #1 (.conf)
        title: EndeavourOS (6.8.2-arch2-1) (default) (selected)
           id: 70ab16ff5c894495b4afb00663ef9d90-6.8.2-arch2-1.conf
       source: /efi//loader/entries/70ab16ff5c894495b4afb00663ef9d90-6.8.2-arch2-1.conf
     sort-key: endeavouros-6.8.2-arch2-1
      version: 6.8.2-arch2-1
   machine-id: 70ab16ff5c894495b4afb00663ef9d90
        linux: /efi//70ab16ff5c894495b4afb00663ef9d90/6.8.2-arch2-1/linux
       initrd: /efi//70ab16ff5c894495b4afb00663ef9d90/6.8.2-arch2-1/initrd
      options: nvme_load=YES nowatchdog rw rootflags=subvol=/@ root=UUID=0e7d2631-ad19-41c7-add3-35ffab4bb532 systemd.machine_id=70ab16ff5c894495b4afb00663ef9d90

         type: Boot Loader Specification Type #1 (.conf)
        title: EndeavourOS (6.8.2-arch2-1-fallback)
           id: 70ab16ff5c894495b4afb00663ef9d90-6.8.2-arch2-1-fallback.conf
       source: /efi//loader/entries/70ab16ff5c894495b4afb00663ef9d90-6.8.2-arch2-1-fallback.conf
     sort-key: endeavouros-6.8.2-arch2-1-fallback
      version: 6.8.2-arch2-1-fallback
   machine-id: 70ab16ff5c894495b4afb00663ef9d90
        linux: /efi//70ab16ff5c894495b4afb00663ef9d90/6.8.2-arch2-1/linux
       initrd: /efi//70ab16ff5c894495b4afb00663ef9d90/6.8.2-arch2-1/initrd-fallback
      options: nvme_load=YES nowatchdog rw rootflags=subvol=/@ root=UUID=0e7d2631-ad19-41c7-add3-35ffab4bb532 systemd.machine_id=70ab16ff5c894495b4afb00663ef9d90

         type: Automatic
        title: Windows Boot Manager
           id: auto-windows
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f

         type: Automatic
        title: Reboot Into Firmware Interface
           id: auto-reboot-to-firmware-setup
       source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
Venom1991 commented 4 months ago

@mstio

Hm, I'm not really sure what that's supposed to be but it isn't even remotely similar to the boot stanza found in the example.

mstio commented 4 months ago

I'm sorry, can you hint me to the command to display the stanza? I'm not familiar with this. Thx.

Venom1991 commented 4 months ago

It's supposed to be defined inside rEFInd's configuration file (refind.conf, located on your ESP):

mstio commented 4 months ago

As far as I can tell, after using refind-install the /efi/EFI/refind/refind.conf still contains the default values.

There is a /boot/refind_linux.conf containing :


"Boot with standard options"  "nvme_load=YES nowatchdog rw rootflags=subvol=/@ root=UUID=0e7d2631-ad19-41c7-add3-35ffab4bb532 systemd.machine_id=70ab16ff5c894495b4afb00663ef9d90"
"Boot to single-user mode"    "nvme_load=YES nowatchdog rw rootflags=subvol=/@ root=UUID=0e7d2631-ad19-41c7-add3-35ffab4bb532 systemd.machine_id=70ab16ff5c894495b4afb00663ef9d90 single"
"Boot with minimal options"   "ro root=/dev/nvme0n1p9"
~
Venom1991 commented 4 months ago

Nope, that config file was auto-generated (and output to /boot, not the ESP) by rEFInd's install script and refind-btrfs completely ignores it. A manual boot stanza located defined within rEFInd's main configuration file (located on the ESP) is one of the prerequisites of using this tool.

mstio commented 4 months ago

Allright, so I need to create a manual stanza within the Main conf. I will do so tomorrow and report back.

Thank you so far for the immediate response.

Venom1991 commented 4 months ago

No problem. 👍🏼

mstio commented 3 months ago

Allright.

Next hurdle: I added a boot stanza to the refind.conf

menuentry "Arch Linux" {
        icon     /EFI/refind/icons/os_archlinux.png
        volume   BOOT #801794d3-a44d-408b-a306-b78f46477a49
        loader   /@/boot/vmlinuz-linux
        initrd   /@/boot/initramfs-linux.img
        options  "root=UUID=0e7d2631-ad19-41c7-add3-35ffab4bb532 rw rootflags=subvol=/@"
}

$ journalctl -u refind-btrfs -b

says:

Apr 07 20:25:41 man systemd[1]: Starting Generate rEFInd manual boot stanzas from Btrfs snapshots...
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Scheduling watch for directories: /.snapshots, /.snapshots/46, /.snapshots/47, /.snapshots/48, /.snapshots/49, /.snapshots/50, /.snapshots/51, /.snapshots/52, /.sn>
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Starting the observer with PID 922.
Apr 07 20:25:42 man systemd[1]: Started Generate rEFInd manual boot stanzas from Btrfs snapshots.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: The '/.snapshots/57' snapshot has been created.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the block devices using lsblk.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the physical partition table for device '/dev/nvme0n1' using lsblk.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the live partition table for device '/dev/nvme0n1' using findmnt.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Found the ESP mounted at '/efi' on '/dev/nvme0n1p7'.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Found the root partition on '/dev/nvme0n1p9'.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Searching for snapshots of the '@' subvolume in the '/.snapshots' directory.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Found subvolume '@' mounted as the root partition.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Found 12 snapshots of the '@' subvolume.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Searching for the 'refind.conf' file on '/dev/nvme0n1p7'.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Analyzing the 'refind.conf' file.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Found 1 boot stanza matched with the root partition.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the static partition table for subvolume '@/.snapshots/57/snapshot' from its fstab file.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the static partition table for subvolume '@/.snapshots/56/snapshot' from its fstab file.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the static partition table for subvolume '@/.snapshots/55/snapshot' from its fstab file.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the static partition table for subvolume '@/.snapshots/54/snapshot' from its fstab file.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Initializing the static partition table for subvolume '@/.snapshots/53/snapshot' from its fstab file.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: Found 5 snapshots for addition.
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: WARNING: Detected boot files required by the 'Arch Linux' boot stanza which do not exist in the '@/.snapshots/53/snapshot' subvolume: initramfs-linux.img, vmlinuz->
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: WARNING: Detected boot files required by the 'Arch Linux' boot stanza which do not exist in the '@/.snapshots/57/snapshot' subvolume: initramfs-linux.img, vmlinuz->
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: WARNING: Detected boot files required by the 'Arch Linux' boot stanza which do not exist in the '@/.snapshots/56/snapshot' subvolume: initramfs-linux.img, vmlinuz->
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: WARNING: Detected boot files required by the 'Arch Linux' boot stanza which do not exist in the '@/.snapshots/55/snapshot' subvolume: initramfs-linux.img, vmlinuz->
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: WARNING: Detected boot files required by the 'Arch Linux' boot stanza which do not exist in the '@/.snapshots/54/snapshot' subvolume: initramfs-linux.img, vmlinuz->
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: WARNING: None of the prepared snapshots are matched with the 'Arch Linux' boot stanza!
Apr 07 20:25:42 man /usr/lib/python3.11/site-packages/refind_btrfs/__main__.py[922]: ERROR (refind_btrfs.state_management.conditions/conditions.py/check_boot_stanzas_with_snapshots): None of the matched boot stanzas can be combined with any of the prepared snapshots!

the Refind boot entry also cannot be booted due to:

Invalid loader file!
Error: Not Found while loading vmlinuz-linux

Any ideas where I need to look at?

Venom1991 commented 3 months ago

@mstio

Well, you should check whether the files (initramfs-linux.img and vmlinuz-linux) required for booting actually do exist within the (for example) @/.snapshots/57/snapshot subvolume. My guess is that they don't and I wouldn't really know why except maybe for faulty subvolume setup and/or Snapper configuration.

mstio commented 3 months ago

Thanks. I'll do that. Have a nice one.

mstio commented 3 months ago

I am using the arch distro EndeavourOS. They switched from mkinitcpio to dracut. I guess this is part of the reason those file are not present. Be it as it may, I guess this is an somewhat exotic setup for you tremendous tool - so I pause here. Thanks for the support!

Venom1991 commented 3 months ago

I am using the arch distro EndeavourOS. They switched from mkinitcpio to dracut. I guess this is part of the reason those file are not present. Be it as it may, I guess this is an somewhat exotic setup for you tremendous tool - so I pause here. Thanks for the support!

Yeah, I don't personally use dracut so I didn't account for it. Can rEFInd even boot your OS installation?

mstio commented 3 months ago

Jup, it can. After installation Refind added an entry (with a "red boat" icon) that allows entering the efi menu and booting from there. I also successfully added a manual stanza to the refind.conf (peeking at /efi/loader/entries/#####ID######.arch1-1.conf

I used these values for the manual stanza:

linux      /70ab16ff5c894495b4afb00663ef9d90/6.8.4-arch1-1/linux
initrd     /70ab16ff5c894495b4afb00663ef9d90/6.8.4-arch1-1/initrd

and the correct icon appeared in the refind menu at boot. This entry can be booted correctly. The error remains as the tool cant find valid loader/images.

Venom1991 commented 3 months ago

@mstio

You should verify the structure of the /boot directory of a given snapshot. Which files are contained in it (e.g. @/.snapshots/57/snapshot/boot)? Sorry for not replying earlier.

mstio commented 3 months ago

Thanks. Unfortunately I - completely my fault - f**d up the system. I decided on using ext4 / efi for now. Thx for your support and I'll start a new trial sometime in the future.