From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC kernel-helper] proxmox-boot: find root dev for grub default entry as update-grub does
Date: Mon, 12 Oct 2026 22:11:08 +0200 [thread overview]
Message-ID: <20261012201501.977578-1-s.ivanov@proxmox.com> (raw)
Reading the ID that update-grub/grub-mkconfig uses for generating
unique ids for boot-entries from the existing grub.cfg breaks if the
following update-grub call changes the device id, effectively
rendering the pin setting useless.
Reported in our community-forum in context of renamed /dev/nvmeXnYpZ:
https://forum.proxmox.com/threads/186882/
Reproduced in a VM, by attaching a second disk/partition to a
single-disk vdev in rpool (/dev/sda3 becomes /dev/sda3_/dev/sdb3 for
grub).
Instead of relying on potentially outdated information aquire the
root device id the way update grub does it (in /etc/grub.d/10_linux)
I did shortly consider using the displayed title - but this is
explicitly discouraged in the grub-documentation:
https://www.gnu.org/software/grub/manual/grub/grub.html#Simple-configuration
(although I did not manage to get the menu entries to be displayed in
anything by English)
Fixes: 83a41a1 ("fix #3761: proxmox-boot: add pin/unpin for kernel-version")
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
Notes:
sending as RFC, as I'm a bit reluctant to re-create more of update-grub in
our wrapper for it - and given the options would consider:
"Advanced options for Proxmox VE GNU/Linux>Proxmox VE GNU/Linux, with Linux $kver"
actually more readable, but am not sure if there is an option to really
end up with this not being stable, as laid out in the grub-docs
src/proxmox-boot/functions | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/proxmox-boot/functions b/src/proxmox-boot/functions
index a650c6f..54fc9d9 100755
--- a/src/proxmox-boot/functions
+++ b/src/proxmox-boot/functions
@@ -130,11 +130,11 @@ set_grub_default() {
if [ -z "${kver}" ]; then
rm -f "${GRUB_PIN_SNIPPET}"
else
- # grub menu entry ids contain the internal root-device id (e.g. for zfs the GUID of
- # the pool printed in hex) as this is independent of the ESP (or grub location)
- # take it from /boot/grub/grub.cfg
- root_devid=$(sed -rn "s/.*gnulinux-advanced-(.+)['] \{$/\1/p" \
- /boot/grub/grub.cfg)
+ # grub menu entry ids contain the internal root-device id
+ # follow /etc/grub.d/10_linux in how to aquire it
+ . /usr/share/grub/grub-mkconfig_lib
+ GRUB_DEVICE=$(grub-probe --target=device /)
+ root_devid=$(grub_get_device_id "${GRUB_DEVICE}")
entry="gnulinux-advanced-${root_devid}>gnulinux-${kver}-advanced-${root_devid}"
echo "GRUB_DEFAULT=\"${entry}\"" > "${GRUB_PIN_SNIPPET}"
fi
--
2.47.3
reply other threads:[~2026-10-12 20:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261012201501.977578-1-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.