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: 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: 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 [ARGS]" warn "" @@ -207,6 +241,7 @@ usage() { warn " $0 init " warn " $0 clean [--dry-run]" warn " $0 refresh" + warn " $0 kernels " warn " $0 help" } @@ -227,6 +262,10 @@ help() { echo "" echo " refresh all configured EFI system partitions." echo "" + echo "USAGE: $0 kernels " + echo "" + echo " add/remove pve-kernel with ABI 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