public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-kernel-meta 5/5] proxmox-boot: allow to manually specify bootloader
Date: Wed, 16 Feb 2022 12:32:27 +0100	[thread overview]
Message-ID: <1645009992.5z1ctnkhlr.astroid@nora.none> (raw)
In-Reply-To: <<20220214155737.1444136-6-s.ivanov@proxmox.com>

On February 14, 2022 4:57 pm, Stoiko Ivanov wrote:
> this commit adds the optional [--legacy|--uefi] arguments to
> `p-b-t init`. If provided the respective boot-loader is installed
> (regardless of what is found on the esp, and of the boot-mode)

would IMHO also make sense for `reinit` to do it for all configured 
ESPs? granted, it's likely that people will switch from 'not managed by 
p-b-t' to 'managed by p-b-t', and not so likely that they have to switch 
from 'managed by p-b-t, UEFI' to 'managed by p-b-t, legacy' or 
vice-versa, but it's basically free and you never know ;)

> 
> 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>
> ---
>  bin/proxmox-boot-tool | 47 ++++++++++++++++++++++++++++---------------
>  1 file changed, 31 insertions(+), 16 deletions(-)
> 
> diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool
> index c697f64..68401ee 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 [ -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
>  	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"
>  
> @@ -339,7 +347,7 @@ usage() {
>  	warn "USAGE: $0 <commands> [ARGS]"
>  	warn ""
>  	warn "       $0 format <partition> [--force]"
> -	warn "       $0 init <partition>"
> +	warn "       $0 init <partition> [--legacy|--uefi]"
>  	warn "       $0 reinit"
>  	warn "       $0 clean [--dry-run]"
>  	warn "       $0 refresh [--hook <name>]"
> @@ -530,10 +538,17 @@ 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 "$@"
> -- 
> 2.30.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




  parent reply	other threads:[~2022-02-16 11:32 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 ` [pve-devel] [PATCH pve-kernel-meta 4/5] proxmox-boot: init bootloaders based on esp contents Stoiko Ivanov
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 [this message]
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=1645009992.5z1ctnkhlr.astroid@nora.none \
    --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 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