From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-kernel-meta v2 7/8] proxmox-boot: allow to manually specify bootloader
Date: Thu, 3 Mar 2022 20:07:56 +0100 [thread overview]
Message-ID: <20220303190759.3527703-8-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20220303190759.3527703-1-s.ivanov@proxmox.com>
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 <s.ivanov@proxmox.com>
---
added [--legacy|--uefi] to the reinit subcommand as well.
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 acfd6aa..23bbdc9 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() {
@@ -339,8 +347,8 @@ usage() {
warn "USAGE: $0 <commands> [ARGS]"
warn ""
warn " $0 format <partition> [--force]"
- warn " $0 init <partition>"
- warn " $0 reinit"
+ warn " $0 init <partition> [--legacy|--uefi]"
+ warn " $0 reinit [--legacy|--uefi]"
warn " $0 clean [--dry-run]"
warn " $0 refresh [--hook <name>]"
warn " $0 kernel <add|remove> <kernel-version>"
@@ -360,7 +368,7 @@ help() {
echo ""
echo " initialize EFI system partition at <partition> 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 ""
@@ -530,21 +538,29 @@ case "$1" in
usage
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
+ 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
exit 1
fi
- loop_esp_list reinit "$@"
exit 0
;;
'clean')
--
2.30.2
next prev parent reply other threads:[~2022-03-03 19:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 19:07 [pve-devel] [PATCH pve-kernel-meta/pve-installer v2] improve boot-mode switching Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 1/8] rename pve-efiboot-manual-kernels to proxmox-boot-manual-kernels Stoiko Ivanov
2022-03-04 10:51 ` Thomas Lamprecht
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 2/8] proxmox-boot: add reinit subcommand Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 3/8] proxmox-boot: add helpers to check for bootloader configs Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 4/8] proxmox-boot: refresh based on bootloader config instead of bootmode Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 5/8] proxmox-boot: remove now obsolete EFI/proxmoxdir if it exists Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 6/8] proxmox-boot: init bootloaders based on esp contents Stoiko Ivanov
2022-03-03 19:07 ` Stoiko Ivanov [this message]
2022-03-03 19:07 ` [pve-devel] [PATCH pve-kernel-meta v2 8/8] proxmox-boot: fix #3729 add --graceful to bootctl invocation Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH installer v2 1/2] remove /mnt/hostrun after install Stoiko Ivanov
2022-03-03 19:07 ` [pve-devel] [PATCH installer v2 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=20220303190759.3527703-8-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 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.