[pve-devel] [PATCH pve-kernel-meta v2 6/8] proxmox-boot: init bootloaders based on esp contents
Stoiko Ivanov
s.ivanov at proxmox.com
Thu Mar 3 20:07:55 CET 2022
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 <s.ivanov at proxmox.com>
---
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
More information about the pve-devel
mailing list