[pve-devel] [PATCH kernel-meta 05/10] efiboot: add manual kernel list

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jul 12 15:16:46 CEST 2019


with 'kernels <add|remove>' command in pve-efiboot-tool to add/remove
kernels to/from manual kernel list, and honor it when generating lists
of kernels to not autoremove/sync to ESPs

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
Notes:
    this also needs a pve-docs update which I will write once it has been applied.

    I was also not sure whether we want to automatically refresh the
    ESPs here or not?

 bin/pve-efiboot-tool | 65 ++++++++++++++++++++++++++++++++++++++++++++
 efiboot/functions    |  7 +++++
 2 files changed, 72 insertions(+)

diff --git a/bin/pve-efiboot-tool b/bin/pve-efiboot-tool
index 1000bde..5c51cc0 100755
--- a/bin/pve-efiboot-tool
+++ b/bin/pve-efiboot-tool
@@ -200,6 +200,40 @@ refresh() {
 	exec $hookscript
 }
 
+add_kernel() {
+	ver="$1"
+
+	if [ -z "$ver" ]; then
+		warn "E: <kernel-version> is mandatory"
+		warn ""
+		exit 1
+	fi
+
+	if [ ! -e "/boot/vmlinuz-$ver" ]; then
+		warn "E: no kernel image found in /boot for '$ver', not adding."
+		exit 1
+	fi
+	_add_entry_to_list_file "$MANUAL_KERNEL_LIST" "$ver"
+	echo "Added kernel '$ver' to manual kernel list."
+}
+
+remove_kernel() {
+	ver="$1"
+
+	if [ -z "$ver" ]; then
+		warn "E: <kernel-version> is mandatory"
+		warn ""
+		exit 1
+	fi
+
+	if grep -sqFx "$ver" "$MANUAL_KERNEL_LIST"; then
+		_remove_entry_from_list_file "$MANUAL_KERNEL_LIST" "$ver"
+		echo "Removed kernel '$ver' from manual kernel list."
+	else
+		echo "Kernel '$ver' not found in manual kernel list."
+	fi
+}
+
 usage() {
 	warn "USAGE: $0 <commands> [ARGS]"
 	warn ""
@@ -207,6 +241,7 @@ usage() {
 	warn "       $0 init <partition>"
 	warn "       $0 clean [--dry-run]"
 	warn "       $0 refresh"
+	warn "       $0 kernels <add|remove> <kernel-version>"
 	warn "       $0 help"
 }
 
@@ -227,6 +262,10 @@ help() {
 	echo ""
 	echo "    refresh all configured EFI system partitions."
 	echo ""
+	echo "USAGE: $0 kernels <add|remove> <kernel-version>"
+	echo ""
+	echo "    add/remove pve-kernel with ABI <kernel-version> to list of synced kernels, in addition to automatically selected ones."
+	echo ""
 }
 
 if [ -z "$1" ]; then
@@ -268,6 +307,32 @@ case "$1" in
 		refresh
 		exit 0
 	;;
+	'kernels')
+		shift
+		if [ -z "$1" ]; then
+			warn "E: subcommand is mandatory."
+			warn ""
+			usage
+			exit 1
+		fi
+		cmd="$1"
+		case "$cmd" in
+			'add')
+				add_kernel "$2"
+				exit 0
+			;;
+			'remove')
+				remove_kernel "$2"
+				exit 0
+			;;
+			*)
+				warn "E: invalid subcommand '$cmd'."
+				warn ""
+				usage
+				exit 1
+			;;
+		esac
+	;;
 	'help')
 		shift
 		help
diff --git a/efiboot/functions b/efiboot/functions
index b926170..34a7042 100755
--- a/efiboot/functions
+++ b/efiboot/functions
@@ -4,6 +4,8 @@ set -e
 ESP_LIST="/etc/kernel/pve-efiboot-uuids"
 ESPTYPE='c12a7328-f81f-11d2-ba4b-00a0c93ec93b'
 
+MANUAL_KERNEL_LIST="/etc/kernel/pve-efiboot-manual-kernels"
+
 # relative to the ESP mountpoint
 PMX_ESP_DIR="EFI/proxmox"
 PMX_LOADER_CONF="loader/loader.conf"
@@ -44,9 +46,14 @@ kernel_keep_versions() {
 	oldseries="$(echo "$series_metapackages" | head -n2 | tail -n1)"
 	oldseries_latest_kernel="$(echo "$sorted_list" | grep -E "^${oldseries}\.[^ ]+-pve" | head -n1 )"
 
+	if [ -e "$MANUAL_KERNEL_LIST" ]; then
+		manual_kernels="$(cat "$MANUAL_KERNEL_LIST")"
+	fi
+
 	kernels="$(cat <<-EOF
 		$running_version
 		$install_version
+		$manual_kernels
 		$latest_2_versions
 		$series_metapackages
 		$oldseries_latest_kernel
-- 
2.20.1





More information about the pve-devel mailing list