* [RFC kernel-helper] proxmox-boot: find root dev for grub default entry as update-grub does
@ 2026-10-12 20:11 Stoiko Ivanov
0 siblings, 0 replies; only message in thread
From: Stoiko Ivanov @ 2026-10-12 20:11 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-12 20:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 20:11 [RFC kernel-helper] proxmox-boot: find root dev for grub default entry as update-grub does Stoiko Ivanov
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.