Github messages for voidlinux
 help / color / mirror / Atom feed
From: slymattz <slymattz@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] refind: account for btrfs setups when generating manual stanzas
Date: Sun, 25 Feb 2024 16:01:48 +0100	[thread overview]
Message-ID: <20240225150148.DDE322113E@inbox.vuxu.org> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-48906@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 2433 bytes --]

There is an updated pull request by slymattz against master on the void-packages repository

https://github.com/slymattz/void-packages refind
https://github.com/void-linux/void-packages/pull/48906

refind: account for btrfs setups when generating manual stanzas
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### 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

#### 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_)


A patch file from https://github.com/void-linux/void-packages/pull/48906.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-refind-48906.patch --]
[-- Type: text/x-diff, Size: 2751 bytes --]

From 9b3a34a754a12cfa73921bf2a4f8aea32cdb5fba Mon Sep 17 00:00:00 2001
From: Mateusz Sylwestrzak <401237-mattz7@users.noreply.gitlab.com>
Date: Sat, 24 Feb 2024 01:53:23 +0100
Subject: [PATCH 1/2] refind: account for btrfs setups when generating manual
 stanzas

---
 srcpkgs/refind/files/kernel.post-install | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/refind/files/kernel.post-install b/srcpkgs/refind/files/kernel.post-install
index fd18f9c45ffe0..3b416721222f3 100755
--- a/srcpkgs/refind/files/kernel.post-install
+++ b/srcpkgs/refind/files/kernel.post-install
@@ -22,12 +22,27 @@ tmpfile=$(mktemp /tmp/refind.XXXXXXX)
 
 zversion=$(echo "$VERSION" | sed 's/[.]/[.]/g')
 
+# establish ESP mounting point
+efipath=$(echo $REFIND_CONF | sed 's/\/EFI.*$//')
+if [ $efipath = "/boot" ]; then # mounting ESP to /boot with vmlinuz- and intramfs- stored on the EFI partition
+    efiprefix=""
+else
+    efiprefix="\/$(dirname $efipath)" # mounting ESP to /boot/efi or another path
+fi
+rootfslabel=$(blkid -s LABEL -o value $(df -P / | awk 'NR==2 {print $1}'))
+
+# account for the BTRFS setups including subvolumes
+if df -T / | awk 'NR==2 && $2 == "btrfs" {print "Root filesystem is Btrfs"}'; then
+    rootfssubvol=$(btrfs subvolume show / | head -n1)
+    echo "Btrfs subvol for ROOT is: $rootfssubvol"
+fi
+
 zentry=$(cat <<EOF
 menuentry "Void Linux $VERSION" {
-	volume   "Void Linux"
-	loader   /vmlinuz-$VERSION
-	initrd   /initramfs-$VERSION.img
-	options  "$OPTIONS"
+        volume   "$rootfslabel"
+        loader   ${rootfssubvol}${efiprefix}/vmlinuz-$VERSION
+        initrd   ${rootfssubvol}${efiprefix}/initramfs-$VERSION.img
+        options  "$OPTIONS"
 }
 EOF
 )

From 5a8f305b99b2003adcfd8ef9bd6ae02a06756600 Mon Sep 17 00:00:00 2001
From: Mateusz Sylwestrzak <slymattz@gmail.com>
Date: Sun, 25 Feb 2024 15:58:55 +0100
Subject: [PATCH 2/2] refind: remove btrfs-progs from depends

---
 srcpkgs/refind/template | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/refind/template b/srcpkgs/refind/template
index 94eda5ffc1954..5e28116894571 100644
--- a/srcpkgs/refind/template
+++ b/srcpkgs/refind/template
@@ -73,10 +73,7 @@ do_install() {
 	vinstall gptsync/gptsync_${_EFI_ARCH}.efi 644 \
 		usr/share/refind/tools_${_EFI_ARCH}/
 
-
 	vinstall "${FILESDIR}/refind-kernel-hook.conf" 644 etc/default
-	vinstall ${FILESDIR}/kernel.post-install 744 \
-		etc/kernel.d/post-install 50-refind
-	vinstall ${FILESDIR}/kernel.post-remove 744 \
-		etc/kernel.d/post-remove 50-refind
+	vinstall "${FILESDIR}/kernel.post-install" 744 etc/kernel.d/post-install 50-refind
+	vinstall "${FILESDIR}/kernel.post-remove" 744 etc/kernel.d/post-remove 50-refind
 }

  parent reply	other threads:[~2024-02-25 15:01 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-24  1:28 [PR PATCH] " slymattz
2024-02-24 11:19 ` [PR PATCH] [Updated] " slymattz
2024-02-25 13:45 ` slymattz
2024-02-25 14:51 ` sgn
2024-02-25 14:53 ` [PR REVIEW] " sgn
2024-02-25 15:01 ` slymattz [this message]
2024-02-25 15:34 ` ahesford
2024-02-25 16:06 ` slymattz
2024-02-25 16:12 ` slymattz
2024-02-25 16:43 ` [PR PATCH] [Updated] " slymattz
2024-02-25 16:55 ` slymattz
2024-02-25 16:59 ` slymattz
2024-02-27 14:32 ` slymattz
2024-02-27 14:35 ` slymattz
2024-03-04 11:01 ` [PR REVIEW] " slymattz
2024-03-06 19:49 ` [PR PATCH] [Updated] " slymattz
2024-03-06 20:27 ` slymattz
2024-03-07 12:55 ` slymattz
2024-03-08 16:39 ` [PR PATCH] [Updated] " slymattz
2024-03-08 16:41 ` slymattz
2024-03-09  0:49 ` sgn
2024-03-09  8:21 ` slymattz
2024-03-09 20:30 ` slymattz
2024-03-14 19:05 ` slymattz
2024-03-15 18:15 ` [PR REVIEW] " ahesford
2024-03-15 18:15 ` ahesford
2024-03-15 18:15 ` ahesford
2024-03-16 21:03 ` [PR PATCH] [Updated] " slymattz
2024-03-16 21:09 ` slymattz
2024-03-18 15:18 ` ahesford
2024-03-18 17:33 ` [PR PATCH] [Updated] " slymattz
2024-03-18 17:36 ` slymattz
2024-03-18 17:37 ` slymattz
2024-03-18 18:50 ` [PR PATCH] [Updated] " slymattz
2024-03-18 18:53 ` slymattz
2024-03-18 19:09 ` slymattz
2024-03-18 19:40 ` [PR PATCH] [Updated] " slymattz
2024-03-18 19:47 ` slymattz
2024-03-18 20:12 ` slymattz
2024-03-18 20:13 ` slymattz
2024-03-19 18:31 ` slymattz
2024-03-21 14:49 ` [PR PATCH] [Updated] " slymattz
2024-03-21 15:23 ` [PR PATCH] [Closed]: " ahesford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240225150148.DDE322113E@inbox.vuxu.org \
    --to=slymattz@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).