void-packages icon indicating copy to clipboard operation
void-packages copied to clipboard

refind: account for btrfs setups when generating manual stanzas

Open slymattz opened this issue 1 year ago • 5 comments

Testing the changes

  • I tested the changes in this PR: briefly

Local build testing

I built this PR locally for my native architecture, x86_64-glibc as well as for aarch64-glibc [EDIT: Feb 26 09:34:52 PM CET 2024].

My setup

/etc/default/refind-kernel-hook.conf

#!/bin/sh

# Change this line to 1 to update refind conf whenever new kernel is installed
UPDATE_REFIND_CONF=1

# refind.conf location
# It usually stays in
#
# /boot/EFI/refind/refind.conf
#       if you use all default configuration and EFI partition mounted to /boot
# /boot/efi/EFI/refind/refind.conf
#       if using default configuration and EFI partition mounted to /boot/efi
# /boot/EFI/BOOT/refind.conf
#       if you run refind-install --usedefault and EFI partition mounted to /boot
# /boot/efi/EFI/BOOT/refind.conf
#       likewise, EFI mounted to /boot/efi
# /efi/EFI/refind/refind.conf
# /efi/EFI/BOOT/refind.conf
REFIND_CONF=/boot/efi/EFI/refind/refind.conf

# addition kernel cmdline
OPTIONS="root=UUID=a9ee6e45-d348-4214-9560-0d0c73ab8077 ro rootflags=subvol=void/ROOT quiet loglevel=4 mem_sleep_default=deep i915.modeset=1 video=1920x1080"

/boot/efi/EFI/refind/refind.conf

timeout 5
use_nvram false
scanfor internal,optical,manual
also_scan_dirs void/ROOT/boot
dont_scan_volumes FIRE1TB-EFI,FIRE1TB-tank,KC1TB-EFI,KC2TB-EFI,KC2TB-tank,WD1TB-EFI,WD1TB-tank
resolution 1920 1080

scanfor internal works as it takes also_scan_dirs as a prefix to where to find vmlinuz and initramfs files.

However, manual stanzas generated by /etc/kernel.d/post-install/50-refind hook get me nowhere near bootable entries.

The patch that I came up with may not be perfect but it works on my installation.

Further testing is needed, especially for people with EFI mounted at /boot and using filesystems other than btrfs.

To test the changes one needs to run xbps-reconfigure -f linux6.6 or whichever kernel one's running (also make sure to adjust the settings in /etc/default/refind-kernel-hook.conf)

slymattz avatar Feb 24 '24 01:02 slymattz

@sgn @ahesford May I ask you to please take a look at this commit. I already set my git commit email to a non-no-reply one. I would probably have to git-rebase or something.

As for the errors in compiling for aarch64, I have no idea why this package didn't compile successfully this time around as I had made no changes to the compilation phase but only to the post-install kernel hook.

Thank you in advance :)

slymattz avatar Feb 25 '24 13:02 slymattz

@sgn @ahesford May I ask you to please take a look at this commit. I already set my git commit email to a non-no-reply one. I would probably have to git-rebase or something.

git commit --amend --reset-author

sgn avatar Feb 25 '24 14:02 sgn

ac296e2 I tested the following setup:

/etc/default/refind-kernel-hook.conf

#!/bin/sh

# Change this line to 1 to update refind conf whenever new kernel is installed
UPDATE_REFIND_CONF=1

# refind.conf location
# It usually stays in
#
# /boot/EFI/refind/refind.conf
#       if you use all default configuration and EFI partition mounted to /boot
# /boot/efi/EFI/refind/refind.conf
#       if using default configuration and EFI partition mounted to /boot/efi
# /boot/EFI/BOOT/refind.conf
#       if you run refind-install --usedefault and EFI partition mounted to /boot
# /boot/efi/EFI/BOOT/refind.conf
#       likewise, EFI mounted to /boot/efi
# /efi/EFI/refind/refind.conf
# /efi/EFI/BOOT/refind.conf
REFIND_CONF=/boot/efi/EFI/refind/refind.conf

# Set the label of the Void Linux filesystem
REFIND_LABEL="KC1TB-tank"

# Set the path pointing to where rEFInd should look for vmlinuz and initramfs files, e.g. /boot
REFIND_BOOT_PREFIX=void/ROOT/boot

# Additional kernel cmdline parameters
OPTIONS="root=UUID=a9ee6e45-d348-4214-9560-0d0c73ab8077 ro rootflags=subvol=void/ROOT mem_sleep_default=deep i915.modeset=1 video=1920x1080 loglevel=4"

After running xbps-reconfigure -f linux6.6 linux6.1 and rebooting, the manual boot entries boot successfully :)

slymattz avatar Feb 25 '24 16:02 slymattz

@sgn maintainer ping

Although initially my PR focused on btrfs setups, the simple changes proposed by @ahesford in both /etc/default/refind-kernel-hook.conf and /etc/kernel.d/post-install/50-refind are more universal as they can save a lot of trouble when installing Void manually (either through chroot from a different distribution or xchroot from Void). My argument is that these ways of installation are officially documented in Void Linux Docs (so refind could include the appropriate changes). On top of that, the part where mkfs.ext4 is listed (see https://docs.voidlinux.org/installation/guides/chroot.html#prepare-filesystems) doesn't mention the necessity to use -L "Void Linux" for painless installation of refind. Even if it did mention this detail, I believe REFIND_CONF and REFIND_BOOT_PREFIX would have to be tweaked if we were to retain the partition-and-filesystem setup proposed in Docs (see https://docs.voidlinux.org/installation/guides/chroot.html#configure-fstab).

P.S. the first workflow run failed for aarch64 (both glibc and musl) but I ran a cross-compilation of aarch64-glibc on the upstream tree yesterday and it succeeded this time so the compilation errors must've had to do with some dependency incompatibilities at the time or something. That's my guess.

What do y'all think?

slymattz avatar Feb 27 '24 14:02 slymattz

As rEFInd won't cross-compile for aarch64 (both glibc and musl), I created this bug report https://github.com/void-linux/void-packages/issues/49170

slymattz avatar Mar 07 '24 12:03 slymattz

Why do you remove the patch?

sgn avatar Mar 09 '24 00:03 sgn

@sgn When you take a look at the entire thing - https://github.com/void-linux/void-packages/pull/48906/files, you'll see that the patch is not removed but it comes with your new patch. Also the name is changed from add-cross-compile-support.patch to add-cross-compile-support-and-fix-binutils-aarch64.patch to reflect the added changes. If you want me to squash any of the three commits, please let me know.

slymattz avatar Mar 09 '24 08:03 slymattz

@ahesford @sgn is this PR mergable?

If I were to argue for the merge, I'd say that not only does it introduce sgn's patch that fixes aarch64 build, but it also makes necessary changes in the post-install kernel hook. So far, the hook has only been able to generate entries that work with EFI mounted in /boot. I'm really surprised no one ever raised this issue before.

refind-path Source: https://wiki.archlinux.org/title/REFInd#For_manual_boot_stanzas

Given what I said before, I would even argue that the defaults could be REFIND_CONF=/boot/efi/EFI/refind/refind.conf and REFIND_BOOT_PREFIX=/boot since this is the standard approach of keeping kernels as part of the ROOTFS filesystem. Mounting the EFI part in /boot/efi (as opposed to /boot) is also recommended in the official Void docs. Although some people do store kernels on the EFI partition, I doubt whether this is a standard approach.

Looking forward to hearing from you guys :)

slymattz avatar Mar 14 '24 19:03 slymattz

I don't think you should rename the patch; its original name is sufficiently descriptive, and changing the name makes tracking changes a little more confusing.

ahesford avatar Mar 18 '24 15:03 ahesford

I don't think you should rename the patch; its original name is sufficiently descriptive, and changing the name makes tracking changes a little more confusing.

OK, done. Is it OK now? :)

slymattz avatar Mar 18 '24 17:03 slymattz

image

Got a lint error saying the second line should be blank. So I amended the description of the last commit and added an extra return line after subject so that git parses body as body. I believe commit 32fff16 should pass the test just fine.

slymattz avatar Mar 18 '24 18:03 slymattz

@ahesford Hi! Can you please review my commit https://github.com/void-linux/void-packages/pull/48906/commits/32fff164aee6fb18296cc394857754a84a88a047 and re-run a workflow check? Thanks in advance.

slymattz avatar Mar 19 '24 18:03 slymattz