Venom1991 / refind-btrfs

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

ERROR (refind_btrfs/__init__.py/main): An unexpected error happened, exiting... #8

Closed xfzv closed 3 years ago

xfzv commented 3 years ago

I'm using refind-btrfsAUR on Arch Linux.

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/sr0' using lsblk.
Initializing the live partition table for device '/dev/sr0' 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' on '/dev/nvme0n1p1'.
Found the root partition on '/dev/mapper/luks'.
Found a separate boot partition on '/dev/nvme0n1p1'.
Searching for snapshots of the '@' subvolume in the '/.snapshots' directory.
Found subvolume '@' mounted as the root partition.
Found 14 snapshots of the '@' subvolume.
Searching for the 'refind.conf' file on '/dev/nvme0n1p1'.
Analyzing the 'refind.conf' file.
ERROR (refind_btrfs/__init__.py/main): An unexpected error happened, exiting...
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/refind_btrfs/__init__.py", line 80, in main
    exit_code = runnable.run()
  File "/usr/lib/python3.9/site-packages/refind_btrfs/console/cli_runner.py", line 49, in run
    if not machine.run():
  File "/usr/lib/python3.9/site-packages/refind_btrfs/state_management/refind_btrfs_machine.py", line 102, in run
    while model.next_state():
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 393, in trigger
    return self.machine._process(func)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 1148, in _process
    return trigger()
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 411, in _trigger
    return self._process(event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 420, in _process
    if trans.execute(event_data):
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 272, in execute
    self._change_state(event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 282, in _change_state
    event_data.machine.get_state(self.dest).enter(event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 124, in enter
    event_data.machine.callbacks(self.on_enter, event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 1083, in callbacks
    self.callback(func, event_data)
  File "/usr/lib/python3.9/site-packages/transitions/core.py", line 1104, in callback
    func(*event_data.args, **event_data.kwargs)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/state_management/model.py", line 168, in initialize_matched_boot_stanzas
    refind_config = self.refind_config
  File "/usr/lib/python3.9/site-packages/refind_btrfs/state_management/model.py", line 372, in refind_config
    return refind_config_provider.get_config(esp)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/file_refind_config_provider.py", line 105, in get_config
    return self._read_config_from(none_throws(config_file_path))
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/file_refind_config_provider.py", line 273, in _read_config_from
    RefindConfig(config_file_path)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/refind_config.py", line 54, in with_boot_stanzas
    self._boot_stanzas = list(boot_stanzas)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/file_refind_config_provider.py", line 309, in _map_to_boot_stanzas
    BootStanza, boot_stanza_context.accept(boot_stanza_visitor)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/antlr4/RefindConfigParser.py", line 287, in accept
    return visitor.visitBoot_stanza(self)
  File "/usr/lib/python3.9/site-packages/refind_btrfs/boot/refind_visitors.py", line 67, in visitBoot_stanza
    initrd = only(always_iterable(main_options.get(RefindOption.INITRD)))
  File "/usr/lib/python3.9/site-packages/more_itertools/more.py", line 3063, in only
    raise too_long or ValueError(msg)
ValueError: Expected exactly one item in iterable, but got '/intel-ucode.img', '/initramfs-linux.img', and perhaps more.

I ran sudo systemctl enable refind-btrfs.service.

● refind-btrfs.service - Generate rEFInd manual boot stanzas from Btrfs snapshots
     Loaded: loaded (/usr/lib/systemd/system/refind-btrfs.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2021-03-15 18:51:36 CET; 4s ago
   Main PID: 9917 (python)
      Tasks: 36 (limit: 19066)
     Memory: 19.2M
     CGroup: /system.slice/refind-btrfs.service
             └─9917 /usr/bin/python -m refind_btrfs --run-mode background

mar. 15 18:51:36 archlinux systemd[1]: Starting Generate rEFInd manual boot stanzas from Btrfs snapshots...
mar. 15 18:51:36 archlinux /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[9917]: Scheduling watch for directories: /.snapshots, /.snapshots/1, /.snapshots/10, /.snapshots/11, /.snapshots/12, >
mar. 15 18:51:36 archlinux /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[9917]: Starting the observer with PID 9917.
mar. 15 18:51:36 archlinux systemd[1]: Started Generate rEFInd manual boot stanzas from Btrfs snapshots.
timeout 10
hideui arrows hints
showtools about, reboot, firmware, shutdown
scanfor manual,internal
dont_scan_files + vmlinuz-linux vmlinuz-linux-lts gcdx64.efi shimx64-fedora.efi BOOTX64.EFI
scan_all_linux_kernels false
extra_kernel_version_strings linux-hardened,linux-zen,linux-lts,linux

default_selection "Arch Linux"

menuentry "Arch Linux" {
    icon     /EFI/refind/refind-theme-regular/icons/128-48/os_arch.png
    volume   arch
    loader   /vmlinuz-linux
    initrd   /intel-ucode.img
    initrd   /initramfs-linux.img
    options  "cryptdevice=UUID=[...]:luks root=/dev/mapper/luks rootflags=subvol=@ resume=/dev/mapper/luks resume_offset=16400 quiet rw"
    submenuentry "Boot fallback initramfs" {
        initrd /initramfs-linux-fallback.img
    }
}

include refind-theme-regular/theme.conf

I'm using untouched /etc/refind-btrfs.conf

I have an Arch VM with the exact same setup minus initrd /intel-ucode.img in refind.conf and refind-btrfs works just fine on it.

Any idea? Thanks.

Venom1991 commented 3 years ago

Yep, I don't expect two (or more) "initrd" fields to appear in the boot stanza but at most one. What you can do is this:

options  "cryptdevice=UUID=[...]:luks root=/dev/mapper/luks rootflags=subvol=@ resume=/dev/mapper/luks resume_offset=16400 quiet rw initrd=/intel-ucode.img"

That is, relocate the "initrd" field's value ("/intel-ucode.img) and put it inside the "options" field. This use case isn't really explained well (or mentioned even, it's the first time I see this) in the official rEFInd documentation and it would be quiet a bit of work to support a collection instead of a simple scalar.

You can see the exact error here:

    initrd = only(always_iterable(main_options.get(RefindOption.INITRD)))
File "/usr/lib/python3.9/site-packages/more_itertools/more.py", line 3063, in only
    raise too_long or ValueError(msg)
ValueError: Expected exactly one item in iterable, but got '/intel-ucode.img', '/initramfs-linux.img', and perhaps more.
xfzv commented 3 years ago

Thank you, that did the trick!

Venom1991 commented 3 years ago

Thank you, that did the trick!

No problem. 👍🏼