Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] refind: account for btrfs setups when generating manual stanzas
@ 2024-02-24  1:28 slymattz
  2024-02-24 11:19 ` [PR PATCH] [Updated] " slymattz
                   ` (41 more replies)
  0 siblings, 42 replies; 43+ messages in thread
From: slymattz @ 2024-02-24  1:28 UTC (permalink / raw)
  To: ml

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

There is a new 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**

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


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: 1736 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] 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 fd18f9c45ffe07..3b416721222f3e 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
 )

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2024-03-21 15:23 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-24  1:28 [PR PATCH] refind: account for btrfs setups when generating manual stanzas 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 ` [PR PATCH] [Updated] " slymattz
2024-02-25 15:34 ` [PR REVIEW] " 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

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).