[pve-devel] [PATCH pve-kernel-meta 5/5] proxmox-boot: allow to manually specify bootloader

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Feb 16 12:32:27 CET 2022


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 at 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 at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 





More information about the pve-devel mailing list