Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble adding an icon #44

Closed
BluishHumility opened this issue Feb 19, 2023 · 3 comments
Closed

Trouble adding an icon #44

BluishHumility opened this issue Feb 19, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@BluishHumility
Copy link

Hello,

I am having a little trouble getting an icon to show up on my snapshot stanza boot entry. I do have a custom icon I would like to use, but I can't seem to get any icons to display for some reason. I have tested with an icon from the default set (refind/icons/os_arch.png), and I have also tried to use the default configuration with the mode = "default" setting under [boot-stanza-generation.icon], but instead of showing an icon I recognize I am getting this small box with yellow and black diagonal striping (on the right in this image):

broken_refind_icon

The script announces it is validating the image, and appears to succeed (I have tried an invalid path as well; it is not shy to point out my mistake):

sudo refind-btrfs
Initializing the block devices using lsblk.
Initializing the physical partition table for device '/dev/nvme0n1' using lsblk.
Analyzing the 'refind-btrfs.conf' file.
Initializing the live partition table for device '/dev/nvme0n1' using findmnt.
Found the ESP mounted at '/efi' on '/dev/nvme0n1p1'.
Found the root partition on '/dev/nvme0n1p2'.
Searching for snapshots of the 'eos-kde' subvolume in the '/.snapshots' directory.
Found subvolume 'eos-kde' mounted as the root partition.
Found 14 snapshots of the 'eos-kde' subvolume.
Searching for the 'refind.conf' file on '/dev/nvme0n1p1'.
Found 1 boot stanza matched with the root partition.
Validating the 'EOS_snapshot.png' file.
Writing to the 'btrfs-snapshot-stanzas/e798748f-c287-43e6-b675-cf376345f211_vmlinuz-linux-zen.conf' file.

The stanza that is generated shows the expected path for the icon, here is the top part of the stanza:

File: e798748f-c287-43e6-b675-cf376345f211_vmlinuz-linux-zen.conf
menuentry "EOS-KDE (rwsnap_2023-02-19_14-02-20_ID784)" {
    icon /EOS_snapshot.png
    volume e798748f-c287-43e6-b675-cf376345f211
    loader /eos-kde/root/.refind-btrfs/rwsnap_2023-02-19_14-02-20_ID784/boot/vmlinuz-linux-zen
    initrd /eos-kde/root/.refind-btrfs/rwsnap_2023-02-19_14-02-20_ID784/boot/initramfs-linux-zen.img
    options "root=UUID=5fa54f34-b5fc-40be-8092-8ba34ced9eba rw rootflags=subvol=eos-kde/root/.refind-btrfs/rwsnap_2023-02-19_14-02-20_ID784 nvme.noacpi=1 nowatchdog"

The image is in the same directory as the main refind.conf file, but I have tested moving it to other directories like ../refind/icons and .../refind/btrfs-snapshot-stanzas/ as well with the same result (the script validates the image, but the icon doesn't show up as I would expect).

The pillow library is installed. I think something else pulled it in because I didn't explicitly install it, but I did confirm it is there.

pacman -Ss python-pillow
community/python-pillow 9.4.0-2 [installed]
    Python Imaging Library (PIL) fork

I did see this note in the README:

In case the custom generated boot stanza's icon feature (explained in the next section) is desired it can initially be enabled by installing this package with the following command:

pip install refind-btrfs[custom_icon]

My impression is that instruction is only applicable if the PyPI package is installed, so I have not attempted to do that.

I am using the prebuilt binary from the Chaotic-AUR repo. When I became stumped on the icon I did remove the Chaotic-AUR package and built the AUR package myself with Paru, however this did not have an impact on the issue with the icon.

Other than the issue with the icon, the package seems to be working great--it is finding my snapshots, setting up the rw versions in /root/.refind-btrfs, and the snapshots are bootable.

@Venom1991
Copy link
Owner

Thank you for the detailed explanation of this issue. I'll try and see what is happening when I find the time and I'll report back here.

@Venom1991 Venom1991 self-assigned this Feb 21, 2023
@Venom1991 Venom1991 added the bug Something isn't working label Feb 21, 2023
@BluishHumility
Copy link
Author

I circled back to troubleshoot a little bit this evening and decided to test the mode = "embed_btrfs.logo" option to see if it would work (since the normal icon from my rEFInd stanza is working fine). I stumbled on a clue:

sudo refind-btrfs
Initializing the block devices using lsblk.
Initializing the physical partition table for device '/dev/nvme0n1' using lsblk.
Analyzing the 'refind-btrfs.conf' file.
Initializing the live partition table for device '/dev/nvme0n1' using findmnt.
Found the ESP mounted at '/efi' on '/dev/nvme0n1p1'.
Found the root partition on '/dev/nvme0n1p2'.
Searching for snapshots of the 'eos-kde' subvolume in the '/.snapshots' directory.
Found subvolume 'eos-kde' mounted as the root partition.
Found 12 snapshots of the 'eos-kde' subvolume.
Searching for the 'refind.conf' file on '/dev/nvme0n1p1'.
Found 1 boot stanza matched with the root partition.
Embedding the 'inverted_large.png' logo into the 'eos-kde/boot/eos_logo.png' icon.
ERROR (refind_btrfs.system.pillow_command/pillow_command.py/embed_btrfs_logo_into_source_icon): Image.open('r') call failed!
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/refind_btrfs/system/pillow_command.py", line 135, in embed_btrfs_logo_into_source_icon
    ) as btrfs_logo_image, Image.open(
  File "/usr/lib/python3.10/site-packages/PIL/Image.py", line 3227, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/efi/EFI/refind/eos-kde/boot/eos_logo.png'
ERROR (refind_btrfs.state_management.refind_btrfs_machine/refind_btrfs_machine.py/run): Could not read the '/efi/EFI/refind/eos-kde/boot/eos_logo.png' file!

That path (/efi/EFI/refind/eos-kde/boot/eos_logo.png), as the error message points out, does not exist. It is adding the path to my regular icon (from my boot stanza) to /efi/EFI/refind/. Here is my boot stanza:

menuentry "EOS-KDE" {                                                                                           
    volume  e798748f-c287-43e6-b675-cf376345f211                                                                
    icon    /eos-kde/boot/eos_logo.png                                                                          
    loader  /eos-kde/boot/vmlinuz-linux-zen                                                                     
    initrd  /eos-kde/boot/initramfs-linux-zen.img                                                               
    options "root=UUID=5fa54f34-b5fc-40be-8092-8ba34ced9eba rw rootflags=subvol=eos-kde nvme.noacpi=1 nowatchdog
    submenuentry "Boot fallback" {                                                                              
        initrd /eos-kde/boot/initramfs-linux-zen-fallback.img                                                   
    }                                                                                                           
}

eos-kde is the name of the root subvolume for this installation.

A standard way to write the stanza is with the icon field first, with the path to the icon relative to the EFI partition. However, rEFInd allows for specifying an icon path where the icon is inside the root file system instead of on the EFI partition (in my case, the icon is in /boot) as long as the icon field is added after the volume field in the stanza.

It appears refind-btrfs is not aware that this is allowed, and is interpreting the path to my boot directory (/boot inside the subvolume of eos-kde) as a path relative to the refind.conf directory.

Armed with this clue, I moved the icon from the boot directory to the EFI partition, and moved the icon field above the volume field in my rEFInd stanza. The script succeeded after this change, and the boot screen correctly showed the Btrfs-embedded logo.

Then, I changed back to mode = "custom", and my custom icon appears!

This last piece I am still scratching my head over, because the custom icon was on the EFI partition with a path relative to the refind.conf directory the whole time. And it was validated by the script. It seems there is no reason for refind-btrfs to be checking on the icon path from the boot stanza to begin with when using a custom icon, because it doesn't need to use it for anything. Still, it does appear that somehow it was causing a problem.

I'll close the issue here since I'm perfectly happy with this workaround. I realize this is kind of an unconventional bug that is unlikely to impact many folks, so I'm not sure if it is even worth to attempt some kind of fix or not, but either way I appreciate you taking a look and I thank you for your time.

@Venom1991
Copy link
Owner

A standard way to write the stanza is with the icon field first, with the path to the icon relative to the EFI partition.

Yeah, I assumed it needs to be somewhere on the ESP and I also mentioned that prerequisite in the config file as well as the fact that it isn't being used as-is but that it's format is also validated.
I could play around with paths some more but I deem this feature out of scope, currently, since it's very easy to circumvent this validation by simply relocating the desired custom icon to the ESP - just as you did so yourself.

This last piece I am still scratching my head over, because the custom icon was on the EFI partition with a path relative to the refind.conf directory the whole time. And it was validated by the script.

This I don't understand, honestly. Perhaps rEFInd itself was somehow confused by the path, couldn't find the icon and used that ugly fallback icon instead? Still, that doesn't explain how it managed to find it afterwards. 😕

Anyhow, I'm glad it worked out for you in the end and thank you for a detailed subsequent reply. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants