public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-kernel-meta 4/5] proxmox-boot: init bootloaders based on esp contents
Date: Mon, 14 Feb 2022 16:57:34 +0100	[thread overview]
Message-ID: <20220214155737.1444136-5-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20220214155737.1444136-1-s.ivanov@proxmox.com>

in addition to installing the boot loader for the current bootmode
(grub for legacy, systemd-boot for uefi) also install the bootloader
if its config is already present on the ESP.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 bin/proxmox-boot-tool | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool
index 320f49b..c697f64 100755
--- a/bin/proxmox-boot-tool
+++ b/bin/proxmox-boot-tool
@@ -127,6 +127,9 @@ format() {
 init_bootloader() {
 	part="$1"
 
+	install_sd_boot=""
+	install_grub=""
+
 	_get_partition_info "$part"
 
 	if [ -z "$PARTTYPE" ] || [ "$PARTTYPE" != "$ESPTYPE" ]; then
@@ -150,16 +153,35 @@ init_bootloader() {
 	echo "Mounting '$part' on '$esp_mp'."
 	mount -t vfat "$part" "$esp_mp"
 
+	if [ -e "${esp_mp}/$PMX_LOADER_CONF" ]; then
+		install_sd_boot=1
+	fi
+	if [ -d "${esp_mp}/grub" ]; then
+		install_grub=1
+	fi
+	# always init for the current boot-mode
 	if [ -d /sys/firmware/efi ]; then
+	    install_sd_boot=1
+	else
+	    install_grub=1
+	fi
+
+	if [ -n "$install_sd_boot" ]; then
 		echo "Installing systemd-boot.."
 		mkdir -p "$esp_mp/$PMX_ESP_DIR"
-		bootctl --path "$esp_mp" install
+		bootctl_args="--path ${esp_mp}"
+		if [ ! -d /sys/firmware/efi ]; then
+			bootctl_args="${bootctl_args} --no-variables"
+		fi
 
+		bootctl ${bootctl_args} install
 		echo "Configuring systemd-boot.."
 		echo "timeout 3" > "$esp_mp/$PMX_LOADER_CONF.tmp"
 		echo "default proxmox-*" >> "$esp_mp/$PMX_LOADER_CONF.tmp"
 		mv "$esp_mp/$PMX_LOADER_CONF.tmp" "$esp_mp/$PMX_LOADER_CONF"
-	else
+	fi
+
+	if [ -n "$install_grub" ]; then
 		echo "Installing grub i386-pc target.."
 		grub-install.real \
 			--boot-directory $esp_mp \
-- 
2.30.2





  parent reply	other threads:[~2022-02-14 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 15:57 [pve-devel] [PATCH pve-kernel-meta/pve-installer] improve boot-mode switching Stoiko Ivanov
2022-02-14 15:57 ` [pve-devel] [PATCH pve-kernel-meta 1/5] rename pve-efiboot-manual-kernels to proxmox-boot-manual-kernels Stoiko Ivanov
     [not found]   ` <<20220214155737.1444136-2-s.ivanov@proxmox.com>
2022-02-16 11:29     ` Fabian Grünbichler
2022-02-14 15:57 ` [pve-devel] [PATCH pve-kernel-meta 2/5] proxmox-boot: add reinit subcommand Stoiko Ivanov
2022-02-14 15:57 ` [pve-devel] [PATCH pve-kernel-meta 3/5] proxmox-boot: refresh based on bootloader config instead of bootmode Stoiko Ivanov
     [not found]   ` <<<20220214155737.1444136-4-s.ivanov@proxmox.com>
2022-02-16 11:31     ` Fabian Grünbichler
2022-02-14 15:57 ` Stoiko Ivanov [this message]
2022-02-14 15:57 ` [pve-devel] [PATCH pve-kernel-meta 5/5] proxmox-boot: allow to manually specify bootloader Stoiko Ivanov
     [not found]   ` <<20220214155737.1444136-6-s.ivanov@proxmox.com>
2022-02-16 11:32     ` Fabian Grünbichler
2022-02-14 15:57 ` [pve-devel] [PATCH installer 1/2] remove /mnt/hostrun after install Stoiko Ivanov
2022-02-14 15:57 ` [pve-devel] [PATCH installer 2/2] use proxmox-boot-tool for all uefi installs Stoiko Ivanov

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=20220214155737.1444136-5-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal