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 E98DB694DC for ; Fri, 11 Mar 2022 20:06:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4991D2803B for ; Fri, 11 Mar 2022 20:06:06 +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 0BDD927EFB for ; Fri, 11 Mar 2022 20:06:02 +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 D6D8741891 for ; Fri, 11 Mar 2022 20:06:01 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Fri, 11 Mar 2022 20:05:45 +0100 Message-Id: <20220311190548.2937377-8-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220311190548.2937377-1-s.ivanov@proxmox.com> References: <20220311190548.2937377-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.212 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 v3 7/8] proxmox-boot: allow to manually specify bootloader 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: Fri, 11 Mar 2022 19:06:07 -0000 this commit adds the optional [--legacy|--uefi] arguments to `p-b-t init` and `p-b-t reinit`. If provided the respective boot-loader is installed (regardless of what is found on the esp, and of the boot-mode) This should make switching the boot-mode possible without the need to boot into a live CD, chrooting and manually running the necessary p-b-t commands. Signed-off-by: Stoiko Ivanov --- bin/proxmox-boot-tool | 60 +++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool index 9731204..164ae91 100755 --- a/bin/proxmox-boot-tool +++ b/bin/proxmox-boot-tool @@ -126,6 +126,7 @@ format() { init_bootloader() { part="$1" + mode="$2" install_sd_boot="" install_grub="" @@ -153,17 +154,25 @@ 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 + if [ -n "$mode" ]; then + if [ "$mode" = "--uefi" ]; then + install_sd_boot=1 + elif [ "$mode" = "--legacy" ]; then + install_grub=1 + fi else - install_grub=1 + if mountpoint_has_sd_boot "${esp_mp}"; then + install_sd_boot=1 + fi + if mountpoint_has_grub "${esp_mp}"; 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 fi if [ -n "$install_sd_boot" ]; then @@ -192,7 +201,6 @@ init_bootloader() { fi echo "Unmounting '$part'." umount "$part" - echo "Adding '$part' to list of synced ESPs.." _add_entry_to_list_file "$ESP_LIST" "$UUID" @@ -209,7 +217,7 @@ reinit() { warn "WARN: ${path} does not exist - clean '${ESP_LIST}'! - skipping" return fi - init_bootloader "$path" + init_bootloader "$path" "$@" } _clean_impl() { @@ -345,10 +353,10 @@ usage() { warn " $0 format [--force]" fi if [ -z "$subcmd" ] || [ "$subcmd" = "init" ]; then - warn " $0 init " + warn " $0 init [--legacy|--uefi]" fi if [ -z "$subcmd" ] || [ "$subcmd" = "reinit" ]; then - warn " $0 reinit" + warn " $0 reinit [--legacy|--uefi]" fi if [ -z "$subcmd" ] || [ "$subcmd" = "clean" ]; then warn " $0 clean [--dry-run]" @@ -379,7 +387,7 @@ help() { echo "" echo " initialize EFI system partition at for automatic synchronization of pve-kernels and their associated initrds." echo "" - echo "USAGE: $0 reinit" + echo "USAGE: $0 reinit [--legacy|--uefi]" echo "" echo " reinitialize all configured EFI system partitions from $ESP_LIST." echo "" @@ -563,21 +571,29 @@ case "$1" in usage "init" exit 1 fi - init_bootloader "$@" - echo "Refreshing kernels and initrds.." - refresh - exit 0 + if [ -z "$2" ] || [ "$2" = "--legacy" ] || [ "$2" = "--uefi" ]; then + init_bootloader "$@" + echo "Refreshing kernels and initrds.." + refresh + exit 0 + else + warn "E: invalid 'init' mode '$2'." + warn "" + usage "init" + exit 1 + fi ;; 'reinit') reexec_in_mountns "$@" shift - if [ "$#" -eq 1 ]; then - warn "E: no arguments allowed." + if [ -z "$1" ] || [ "$1" = "--legacy" ] || [ "$1" = "--uefi" ]; then + loop_esp_list reinit "$@" + else + warn "E: invalid 'init' mode '$1'." warn "" usage "reinit" exit 1 fi - loop_esp_list reinit "$@" exit 0 ;; 'clean') -- 2.30.2