[pve-devel] [RFC pve-kernel-meta 4/5] proxmox-boot: use grub for UEFI boot

Stoiko Ivanov s.ivanov at proxmox.com
Tue Feb 1 23:03:30 CET 2022


originally systemd-boot was chosen for UEFI installs because of it's
less invasive and economical configuration (add a few short files,
instead of having update-grub run through /dev a few times identifying
potentially interesting devices)

However with the change to proxmox-boot-tool and also handling
non-uefi installations we can deal with grub installed on an ESP
anyways.

This changeset changes proxmox-boot-tool to use grub for both
boot-modes, unifying the experience (e.g. not needing to check the
boot mode in order to set kernel commandline arguments)

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 bin/proxmox-boot-tool        | 23 ++++++++---------------
 proxmox-boot/zz-proxmox-boot | 15 ---------------
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool
index 5397694..d8caa6b 100755
--- a/bin/proxmox-boot-tool
+++ b/bin/proxmox-boot-tool
@@ -150,26 +150,19 @@ init_bootloader() {
 	echo "Mounting '$part' on '$esp_mp'."
 	mount -t vfat "$part" "$esp_mp"
 
-	echo "Installing systemd-boot.."
-	mkdir -p "$esp_mp/$PMX_ESP_DIR"
-	bootctl_args="--path ${esp_mp}"
+	echo "Installing grub x86_64 target.."
+	grub_common_args="--boot-directory ${esp_mp} --no-floppy --bootloader-id=proxmox"
+	grub_efi_args="$grub_common_args --target=x86_64-efi --efi-directory=$esp_mp"
 	if [ ! -d /sys/firmware/efi ]; then
-		bootctl_args="${bootctl_args} --no-variables"
+		grub_efi_args="$grub_efi_args --no-nvram"
 	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"
+	grub-install.real ${grub_efi_args} "/dev/$PKNAME"
 
 	echo "Installing grub i386-pc target.."
-	grub-install.real \
-		--boot-directory $esp_mp \
-		--target i386-pc \
-		--no-floppy \
-		--bootloader-id='proxmox' \
-		"/dev/$PKNAME"
+	grub_legacy_args="$grub_common_args --target=i386-pc"
+	grub-install.real ${grub_legacy_args} "/dev/$PKNAME"
+
 	echo "Unmounting '$part'."
 	umount "$part"
 
diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot
index 5609af2..60948ac 100755
--- a/proxmox-boot/zz-proxmox-boot
+++ b/proxmox-boot/zz-proxmox-boot
@@ -75,10 +75,6 @@ update_esp_func() {
 		{ warn "creation of mountpoint ${mountpoint} failed - skipping"; return; }
 	mount "${path}" "${mountpoint}" || \
 		{ warn "mount of ${path} failed - skipping"; return; }
-	if [ ! -f "${mountpoint}/$PMX_LOADER_CONF" ]; then
-		warn "${path} contains no loader.conf - skipping"
-		return
-	fi
 	if [ ! -d "${mountpoint}/grub" ]; then
 		warn "${path} contains no grub directory - skipping"
 		return
@@ -89,7 +85,6 @@ update_esp_func() {
 	if [ -e "${PINNED_KERNEL_CONF}" ]; then
 	    pinned_kernel=$(get_first_line "${PINNED_KERNEL_CONF}")
 	fi
-	set_systemd_boot_default "${mountpoint}" "${pinned_kernel}"
 	set_grub_default "${pinned_kernel}"
 	remove_old_kernels "${mountpoint}"
 	mount --bind "${mountpoint}" "/boot"
@@ -123,15 +118,6 @@ copy_and_config_kernels() {
 		warn "	Copying kernel and creating boot-entry for ${kver}"
 		cp --preserve=timestamps "${linux_image}" "${esp}/"
 		cp --preserve=timestamps "${initrd}" "${esp}/"
-
-		# create loader entry
-		cat > "${esp}/loader/entries/proxmox-${kver}.conf" <<- EOF
-			title    ${LOADER_TITLE}
-			version  ${kver}
-			options  ${CMDLINE}
-			linux    /vmlinuz-${kver}
-			initrd   /initrd.img-${kver}
-		EOF
 	done
 
 }
@@ -146,7 +132,6 @@ remove_old_kernels() {
 		warn "	Removing old version ${kver}"
 		rm -rf "${esp}/vmlinuz-${kver}"
 		rm -rf "${esp}/initrd.img-${kver}"
-		rm -f "${esp}/loader/entries/proxmox-${kver}.conf"
 	done
 
 }
-- 
2.30.2






More information about the pve-devel mailing list