all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC proxmox-kernel-helper] zz-proxmox-boot: check removable status
Date: Tue,  4 Mar 2025 11:55:23 +0100	[thread overview]
Message-ID: <20250304105523.2724043-1-f.gruenbichler@proxmox.com> (raw)

if a fallback bootloader is installed, but the Grub packages are not set
up to manage it, inform the user about it. this setup is problematic if
the fallback bootloader is used as boot option (now or in the future),
so it's best to fix it up before a problem occurs.

for proxmox-boot-tool managed ESPs, we always install both when
(re)initing the ESPs, this only affects setup with a regular,
always-mounted, single ESP, such as ext4 on top of LVM.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
not sure whether this is the place we want to do this check in,
suggestions for that or wording welcome ;)

 src/proxmox-boot/zz-proxmox-boot | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/proxmox-boot/zz-proxmox-boot b/src/proxmox-boot/zz-proxmox-boot
index 09f9171..b5bd57d 100755
--- a/src/proxmox-boot/zz-proxmox-boot
+++ b/src/proxmox-boot/zz-proxmox-boot
@@ -243,6 +243,34 @@ check_grub_efi_package() {
 	warn "Install 'grub-efi-amd64' to get updates."
 }
 
+check_grub_efi_removable_status() {
+	# not booted in EFI, no need to care about removable bootloader
+	if [ ! -d /sys/firmware/efi ]; then
+		return
+	fi
+
+	# no removable bootloader
+	if [ ! -f "/boot/efi/EFI/BOOT/BOOTX64.efi" ]; then
+		return
+	fi
+
+	debconf_value="$(debconf-show --db configdb grub-efi-amd64 grub-pc | grep 'force_efi_extra_removable')"
+
+	# packages already set up to install a removable copy, let's trust that it works
+	if echo "${debconf_value}" | grep -qE ': true$'; then
+		return
+	fi
+
+	echo ""
+	echo "Removable bootloader at '/boot/efi/EFI/BOOT/BOOTX64.efi' found, but Grub packages not set up to update it!"
+	echo "Run the following command:"
+	echo ""
+	echo "echo 'grub-efi-amd64 grub2/force_efi_extra_removable boolean true' | debconf-set-selections -v -u"
+	echo ""
+	echo "Followed by re-installing Grub with 'apt install --reinstall grub-efi-amd64'"
+	echo ""
+}
+
 set -- $DEB_MAINT_PARAMS
 mode="${1#\'}"
 mode="${mode%\'}"
@@ -257,6 +285,7 @@ case $0:$mode in
 		update_esps
 		disable_systemd_boot_hook
 		check_grub_efi_package
+		check_grub_efi_removable_status
 	;;
 	 */postrm.d/*:|*/postrm.d/*:remove)
 		reexec_in_mountns "$@"
@@ -265,6 +294,7 @@ case $0:$mode in
 		update_esps
 		disable_systemd_boot_hook
 		check_grub_efi_package
+		check_grub_efi_removable_status
 	;;
 esac
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

             reply	other threads:[~2025-03-04 10:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04 10:55 Fabian Grünbichler [this message]
2025-03-04 15:11 ` [pve-devel] applied: " Thomas Lamprecht

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=20250304105523.2724043-1-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal