grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] util/grub.d/10_linux.in: Ignore kernel if initrd required bu


From: Didier Spaier
Subject: Re: [PATCH] util/grub.d/10_linux.in: Ignore kernel if initrd required but
Date: Tue, 13 Feb 2024 11:55:23 +0100
User-agent: Mozilla Thunderbird


Le 2/13/24 à 10:42, TJ a écrit :
> 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

So if the issue occurs and this patch is applied a message like:

Missing required 'initrd.img-6.1.0-18-amd64'; ignoring kernel version
6.1.0-18-amd64

will be displayed.

But (speaking as a distribution maintainer) I am not sure that a non-technical
user will understand the consequences, not will know what to do next.

If the distribution's install kernel script keeps at least the kernel in use
when running grub-mkconfig or update-grub (which is a good thing IMO), the
machine will still be able to boot, whether or not the not_working boot entry is
included in the boot menu, but the kernel upgrade will still not be applied.

Shouldn't this issue be solved at the distribution level, e.g. modifying the
kernel install scripts appropriately, at least warning the user that the kernel
upgrade failed and giving some hints how to solve the issue, rather than
applying an upgrade deemed to fail?

Cheers, Didier


> ---
> 
> 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 <linux@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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]