grub-devel
[Top][All Lists]
Advanced

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

Re: Proposed PATCH to allow control of the kernel ordering in grub.cfg


From: Daniel Kiper
Subject: Re: Proposed PATCH to allow control of the kernel ordering in grub.cfg
Date: Thu, 20 Dec 2018 12:53:49 +0100
User-agent: NeoMutt/20170113 (1.7.2)

Hi Jeff,

On Wed, Dec 19, 2018 at 12:50:21AM -0600, Jeff Norden wrote:
> Greetings.
>
> The small patch below adds a new variable (for use by 10_linux) that
> allows you to tweak the ordering of kernels in grub.cfg
>
> When the 10_linux script finds more than one installed kernel, it orders
> them by version number.  If you have several kernels, the one with the
> highest version might be one you are trying out, but not the one that
> you want to use most of the time.
>
> The patch below adds a new /etc/default/grub variable for use by 10_linux.
> The line
>   GRUB_PREFERRED_KERNEL="4.14"
> will cause the 4.14 kernel to be listed before any others.  In particular,
> 4.14 will be the kernel used for the top-level "simple" menu entry.  If
> GRUB_PREFERRED_KERNEL is not set, then the behavior of 10_linux isn't changed.
>
> Background: I've been trying out manjaro lately, which has a nice gui
> for installing multiple kernels.  I discovered that 4.19 wasn't
> interacting well with my video card.  I got tired of having to
> drill-down to the 4.14 kernel entry on each re-boot.  But I wanted to
> keep 4.19 installed so that I could try it out after updates (and maybe
> try to isolate the problem in my "spare" time).
>
> I could have used the GRUB_DEFAULT variable, but that would mean
> disabling GRUB_SAVEDEFAULT, and another member of my household uses the
> windows partition on this computer :-(.  Also, GRUB_DEFAULT would need
> to be adjusted if/when other kernels are added/deleted.
>
> I've been using the attached patch for a month or so with no problems
> (the kernel has been updated and grub.cfg has been re-build several
> times).  Right now, I've have the GRUB_PREFERRED_KERNEL="4.14" line
> commented out (the video problem is fixed - not by me), and the modified
> 10_linux works fine in this mode as well.

This looks like nice commit message. So, please rebase your patch on
latest GRUB2 master branch and repost it using "git format-patch" and
"git send-email". And please do not forget to add your Signed-off-by.
You can check how the commit message should look like using "git log"
in the GRUB2 master branch.

And some minor comments below...

> Thanks,
> -Jeff Norden
>
> ==== cut here ====x snip x=====
>
> diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> index 4532266be..f2dea11e9 100644
> --- a/util/grub.d/10_linux.in
> +++ b/util/grub.d/10_linux.in
> @@ -193,7 +193,14 @@ submenu_indentation=""
>
>  is_top_level=true
>  while [ "x$list" != "x" ] ; do
> -  linux=`version_find_latest $list`
> +  linux=""
> +  if [ "x${GRUB_PREFERRED_KERNEL}" != "x" ]; then
> +    linux=`echo $list | tr ' ' '\n' | grep "${GRUB_PREFERRED_KERNEL}" | tr 
> '\n' ' '`

s/grep/egrep/? And you do not need tr after grep.

> +  fi
> +  if [ "x$linux" = "x" ]; then
> +    linux=$list
> +  fi
> +  linux=`version_find_latest $linux`
>    gettext_printf "Found linux image: %s\n" "$linux" >&2
>    basename=`basename $linux`
>    dirname=`dirname $linux`
>
> diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
> index 33332360e..8d6aecf22 100644
> --- a/util/grub-mkconfig.in
> +++ b/util/grub-mkconfig.in
> @@ -238,7 +238,8 @@ export GRUB_DEFAULT \
>    GRUB_ENABLE_CRYPTODISK \
>    GRUB_BADRAM \
>    GRUB_OS_PROBER_SKIP_LIST \
> -  GRUB_DISABLE_SUBMENU
> +  GRUB_DISABLE_SUBMENU \
> +  GRUB_PREFERRED_KERNEL
>
>  if test "x${grub_cfg}" != "x"; then
>    rm -f "${grub_cfg}.new"
>
> diff --git a/docs/grub.texi b/docs/grub.texi
> index ecaba9d5c..ac07a453f 100644
> --- a/docs/grub.texi
> +++ b/docs/grub.texi
> @@ -1502,6 +1502,24 @@ and @samp{default} (@pxref{default}) environment 
> variables as well as saved
>  default entry using @command{grub-set-default} and value used with
>  @command{grub-reboot}.
>
> address@hidden GRUB_PREFERRED_KERNEL
> +If this option is set, @command{grub-mkconfig} will list kernels that
> +match its value before others.  In particular, the ``top-level'' menu
> +entry (assuming submenus are enabled) will be the one with the highest
> +version number that matches @samp{GRUB_PREFERRED_KERNEL}.  For
> +example, @verb{|GRUB_PREFERRED_KERNEL="4.14"|} will put the 4.14 kernel
> +first in @file{grub.cfg}, even if newer kernel(s) are found.
> +
> +Matching is done via @command{grep} against the file name of the

s/grep/egrep/

Daniel



reply via email to

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