I have recently seen several bugs on Debian and Ubuntu whereby when a new kernel package is installed the host uses DKMS to build a module and that build fails (often the case with nvidia, but can also affect others, e.g. jool).The kernel install scripts stop before the initrd.img has been created but after the kernel image has been installed.
When non-technical owners/operators then follow 'random' suggestions from web searches or support chat and do `update-grub` or `grub-mkconfig` GRUB creates a new menuentry without an "initrd" statement and that results, on booting, with a kernel panic with unobvious messages. This has been a problem for at least a decade but until now no effort has been made to deal with the root cause. If this patch (or modifications of it) is accepted it allows distros to add logic to their kernel package install scripts similar to this, that I've used in a Debian proof-of-concept: diff --git a/debian/templates/image.postinst.in b/debian/templates/image.postinst.in index 25e7dd6546..7041d10a4d 100755 --- a/debian/templates/image.postinst.in +++ b/debian/templates/image.postinst.in @@ -11,6 +11,7 @@ depmod $version if [ -f /lib/modules/$version/.fresh-install ]; then change=install + touch "${image_path%/*}/initrd.img-${version}.required" else change=upgrade fi When in use grub reports e.g: Found linux image: /boot/vmlinuz-6.1.0-18-amd64 Missing required 'initrd.img-6.1.0-18-amd64'; ignoring kernel version 6.1.0-18-amd64 Found linux image: /boot/vmlinuz-6.1.0-18-amd64 Missing required 'initrd.img-6.1.0-18-amd64'; ignoring kernel version 6.1.0-18-amd64 --- On some distros if the kernel package installation fails for some reason an initialramfs file may not be created although it is required for a successful boot. Until now grub will still create the menuentry causing a kernel panic when used (as will happen if it is the default entry after a kernel package upgrade). Allow other tools to indicate that the file must exist for a menuentry for that kernel version to be created. Created by kernel package installation script, or manually, if /boot/${initrd_file}.required exists when /boot/${initrd_file} does not GRUB will skip creating the menuentry for this kernel. Signed-off-by: Tj <li...@iam.tj> --- util/grub.d/10_linux.in | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index cc393be7e..040c15713 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -236,8 +236,15 @@ for linux in ${reverse_sorted_list}; do if test -e "${dirname}/${i}" ; then initrd_real="${i}" break + elif test -e "${dirname}/${i}.required" ; then + gettext_printf "Missing required '%s'; ignoring kernel version %s\n" "$(echo $i)" "$(echo $version)" >&2 + linux="" + break fi done + if test -z "$linux"; then + continue + fi initrd= if test -n "${initrd_early}" || test -n "${initrd_real}"; then -- 2.39.2 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel