I have a theory about the failure path that seems consistent with both
the logs and the exact Noble package scripts.

The confirmed part is that the VirtualBox DKMS hook exited with status
11 while configuring linux-image-6.17.0-14-generic. This stopped
postinst.d before initramfs-tools and zz-update-grub could run. dpkg
reported the error and left the kernel package half-configured. The
vmlinuz file was already present, no matching initrd had been created,
and /usr/lib/linux/triggers/6.17.0-14-generic remained on disk.

My theory is that the GRUB entry was created by a later, unrelated
package operation. On 13 February, removing linux-
image-6.14.0-36-generic ran its post-removal zz-update-grub hook.
Noble's 10_linux scans /boot/vmlinuz-* without checking dpkg state or
the pending trigger marker. It would therefore find the incomplete 6.17
kernel and generate an entry for it even though no initrd existed.

This also explains why changing systemd's 55-initrd.install would not
address the observed path. The DKMS failure had already stopped the
kernel post-install hooks, and the available logs do not show
55-initrd.install taking part in the later GRUB refresh.

If this interpretation is correct, the primary package for the fix would
be grub2. The linux task would still be relevant because kernel
packaging owns the lifecycle of /usr/lib/linux/triggers. VirtualBox was
the trigger for this particular incident, but its Linux 6.17 build
failure has already been fixed in Noble by virtualbox
7.0.16-dfsg-2ubuntu1.3.

One possible fix would be for zz-update-grub to pass the version it is
currently processing to 10_linux. The generator could then skip a kernel
when no real initrd exists, its pending trigger marker is present, and
it is not the version currently being handled by the hook.

This seems like a sensible direction because it prevents an unrelated
update-grub run from publishing an unfinished kernel without rejecting
valid initrdless configurations. I have checked a small prototype for
shell syntax and the main decision paths. The theory still needs to be
confirmed with an end-to-end reproduction using Noble grub2 packages in
a virtual machine.

Potential fix here, which I think could be worth testing (created with
AI help):

--- a/etc/kernel/postinst.d/zz-update-grub
+++ b/etc/kernel/postinst.d/zz-update-grub
@@
 if type systemd-detect-virt >/dev/null 2>&1 &&
    systemd-detect-virt --quiet --container
 then
         exit 0
 fi

+kernel_version="${1-}"
 set -- $DEB_MAINT_PARAMS
 mode="${1#\'}"
 mode="${mode%\'}"

@@
         if [ -e [grub.cfg](http://_vscodecontentref_/0) ]
         then
+                GRUB_KERNEL_HOOK_VERSION="$kernel_version"
+                export GRUB_KERNEL_HOOK_VERSION
                 exec update-grub
         fi

--- a/etc/grub.d/10_linux
+++ b/etc/grub.d/10_linux
@@
   if test -n "${initrd_early}" || test -n "${initrd_real}"
   then
     initrd="${initrd_early} ${initrd_real}"

     initrd_display=
     for i in ${initrd}
     do
       initrd_display="${initrd_display} ${dirname}/${i}"
     done
     gettext_printf "Found initrd image: %s\n" \
       "$(echo $initrd_display)" >&2
   fi

+  if test -z "${initrd_real}" \
+     && test -e "/usr/lib/linux/triggers/${version}" \
+     && test "x${version}" != "x${GRUB_KERNEL_HOOK_VERSION-}"
+  then
+    gettext_printf \
+      "Skipping linux image with pending post-installation trigger and no 
initrd: %s\n" \
+      "$linux" >&2
+    continue
+  fi
+
   dtb=

** Also affects: grub2 (Ubuntu)
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2141741

Title:
  55-initrd.install silently exits 0 when initrd missing causing
  undetectable kernel panic on NVMe systems

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2141741/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to