[pve-devel] [PATCH pve-kernel-meta v2 4/4] proxmox-boot: add pin/unpin functionality for non-p-b-t systems

Stoiko Ivanov s.ivanov at proxmox.com
Fri Feb 4 19:45:36 CET 2022


While running `update-grub` directly in this case is a divergence from
the semantics of the command when p-b-t handles booting it makes the
cleanup in the `next-boot` case a bit tidier.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 bin/proxmox-boot-tool | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/bin/proxmox-boot-tool b/bin/proxmox-boot-tool
index 5d878f6..222d131 100755
--- a/bin/proxmox-boot-tool
+++ b/bin/proxmox-boot-tool
@@ -422,15 +422,31 @@ pin_kernel() {
 		exit 1
 	fi
 	echo "$ver" > "$pin_file"
-	echo "Set kernel '$ver' $PINNED_KERNEL_CONF. Use the 'refresh' command to update the ESPs."
+
+	if [ -f "${ESP_LIST}" ]; then
+		echo "Set kernel '$ver' in $pin_file. Use the 'refresh' command to update the ESPs."
+	else
+		echo "Setting '$ver' as grub default entry and running update-grub."
+		set_grub_default "$ver"
+		update-grub
+	fi
 }
 
 unpin_kernel() {
 	rm -f "$NEXT_BOOT_PIN"
-	echo "Removed $NEXT_BOOT_PIN. Use the 'refresh' command to update the ESPs."
+	echo "Removed $NEXT_BOOT_PIN."
 	if [ -z "$1" ]; then
 		rm -f "$PINNED_KERNEL_CONF"
-		echo "Removed $PINNED_KERNEL_CONF. Use the 'refresh' command to update the ESPs."
+		echo "Removed $PINNED_KERNEL_CONF."
+	fi
+
+	if [ -f "${ESP_LIST}" ]; then
+		echo "Use the 'refresh' command to update the ESPs."
+	else
+		echo "Reset default grub entry and running update-grub."
+		pinned_kernel=$(get_first_line "${PINNED_KERNEL_CONF}")
+		set_grub_default "$pinned_kernel"
+		update-grub
 	fi
 }
 
-- 
2.30.2






More information about the pve-devel mailing list