From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 904F61FF0B3 for ; Wed, 14 Oct 2026 12:42:10 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C73432145A; Wed, 14 Oct 2026 12:42:06 +0200 (CEST) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH kernel-helper v2] kernel hooks: flag pending reboot after installing a new kernel Date: Wed, 14 Oct 2026 12:41:29 +0200 Message-ID: <20261014104153.133304-1-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791974519712 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.128 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HZXCTRERFELUQ7IG2XYTUWM7QD2MGS6X X-Message-ID-Hash: HZXCTRERFELUQ7IG2XYTUWM7QD2MGS6X X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Ship a postinst.d hook that writes /run/reboot-required and records the kernel package in /run/reboot-required.pkgs, similar to the hooks shipped by unattended-upgrades on Debian and update-notifier on Ubuntu. Tools like update-notifier or monitoring checks can then notice that the newly installed kernel is not running yet by checking the existance of this file. See f.ex.: https://github.com/mvo5/unattended-upgrades/blob/master/unattended-upgrade#L867 and: https://git.launchpad.net/ubuntu/+source/update-notifier/tree/data/update-motd-reboot-required Skip this when configuring the currently running kernel, as no reboot is needed then. Came up in https://forum.proxmox.com/threads/156352/ Signed-off-by: Jonas Theisen --- src/proxmox-boot/Makefile | 2 ++ src/proxmox-boot/proxmox-reboot-required | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 src/proxmox-boot/proxmox-reboot-required diff --git a/src/proxmox-boot/Makefile b/src/proxmox-boot/Makefile index 044a024..d9e1c3d 100644 --- a/src/proxmox-boot/Makefile +++ b/src/proxmox-boot/Makefile @@ -1,4 +1,5 @@ KERNEL_HOOKSCRIPTS = proxmox-auto-removal zz-proxmox-boot +KERNEL_POSTINST_HOOKSCRIPTS = proxmox-reboot-required INITRAMFS_HOOKSCRIPTS = proxmox-boot-sync SHARE_FILES = functions GRUB_CFG_SNIPPET = 000_proxmox_boot_header @@ -17,6 +18,7 @@ all: install: install -d $(POSTINSTHOOKDIR) install -m 0755 $(KERNEL_HOOKSCRIPTS) $(POSTINSTHOOKDIR) + install -m 0755 $(KERNEL_POSTINST_HOOKSCRIPTS) $(POSTINSTHOOKDIR) install -d $(POSTRMHOOKDIR) install -m 0755 $(KERNEL_HOOKSCRIPTS) $(POSTRMHOOKDIR) install -d $(POSTINITRAMFSHOOKDIR) diff --git a/src/proxmox-boot/proxmox-reboot-required b/src/proxmox-boot/proxmox-reboot-required new file mode 100755 index 0000000..c645914 --- /dev/null +++ b/src/proxmox-boot/proxmox-reboot-required @@ -0,0 +1,19 @@ +#! /bin/sh +set -e + +# Flag that a reboot is needed to boot the newly installed kernel, following the convention used by +# update-notifier and unattended-upgrades, so that tools like update-notifier or monitoring checks +# notice it. Reconfiguring the currently running kernel does not require a reboot. + +version="$1" + +[ -n "$version" ] || exit 0 +[ "$version" != "$(uname -r)" ] || exit 0 +[ -d /run ] || exit 0 + +pkg="${DPKG_MAINTSCRIPT_PACKAGE:-proxmox-kernel-$version}" + +printf "*** System restart required ***\n" > /run/reboot-required +if ! grep -qxF "$pkg" /run/reboot-required.pkgs 2>/dev/null; then + printf "%s\n" "$pkg" >> /run/reboot-required.pkgs +fi -- 2.47.3