Description: Skip linux image with pending postinst trigger and missing initrd
Author: Viktor Pashaiev <w.paszajew@gmail.com>
Bug-Debian: https://bugs.debian.org/1151014
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2141741
Last-Update: 2026-11-04

--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -445,6 +445,12 @@ for linux in ${reverse_sorted_list}; do
   fi
 
   if test -z "${initramfs}" && test -z "${initrd_real}" ; then
+    if [ "x${GRUB_DISABLE_INITRD}" != "xtrue" ] && [ "x${GRUB_FORCE_PARTUUID}" = "x" ] \
+	&& ( test -x /etc/kernel/postinst.d/initramfs-tools || test -x /etc/kernel/postinst.d/dracut ) \
+	&& ( test -e "/usr/lib/linux/triggers/${version}" || test -e "/usr/lib/linux/triggers/${alt_version}" ); then
+      gettext_printf "Skipping linux image with pending post-installation trigger and no initrd: %s\n" "$linux" >&2
+      continue
+    fi
     # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
     # no initrd or builtin initramfs, it can't work here.
     if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -326,6 +326,12 @@ for current_xen in ${reverse_sorted_xen_
 	fi
 
 	if test -z "${initrd_real}"; then
+	    if [ "x${GRUB_DISABLE_INITRD}" != "xtrue" ] && [ "x${GRUB_FORCE_PARTUUID}" = "x" ] \
+		&& ( test -x /etc/kernel/postinst.d/initramfs-tools || test -x /etc/kernel/postinst.d/dracut ) \
+		&& ( test -e "/usr/lib/linux/triggers/${version}" || test -e "/usr/lib/linux/triggers/${alt_version}" ); then
+		gettext_printf "Skipping linux image with pending post-installation trigger and no initrd: %s\n" "$linux" >&2
+		continue
+	    fi
     # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.
 	    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
 		|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then
