From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id BBEF01FF09B for ; Mon, 12 Oct 2026 22:15:53 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 76EB721386; Mon, 12 Oct 2026 22:15:50 +0200 (CEST) From: Stoiko Ivanov 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 Message-ID: <20261012201501.977578-1-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791836143750 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.696 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_SHORT 0.001 Use of a URL Shortener for very short URL RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: DWI6BVRAXTBEVVQEEYG2LZMLAZBHJ55I X-Message-ID-Hash: DWI6BVRAXTBEVVQEEYG2LZMLAZBHJ55I X-MailFrom: s.ivanov@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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