From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 588EE64907 for ; Thu, 3 Mar 2022 20:08:44 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 22C7235892 for ; Thu, 3 Mar 2022 20:08:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 5A7C33584D for ; Thu, 3 Mar 2022 20:08:12 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2A6F346EB4 for ; Thu, 3 Mar 2022 20:08:12 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Thu, 3 Mar 2022 20:07:55 +0100 Message-Id: <20220303190759.3527703-7-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220303190759.3527703-1-s.ivanov@proxmox.com> References: <20220303190759.3527703-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.225 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH pve-kernel-meta v2 6/8] proxmox-boot: init bootloaders based on esp contents X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2022 19:08:44 -0000 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 --- 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 31a5552..acfd6aa 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