FS#28081 - [grub] Incorrect ordering of kernels in grub.cfg generated by grub-mkconfig
Attached to Project:
Arch Linux
Opened by Xavier D. (magicrhesus) - Tuesday, 24 January 2012, 13:05 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:13 GMT
Opened by Xavier D. (magicrhesus) - Tuesday, 24 January 2012, 13:05 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:13 GMT
|
Details
Description:
The detection order is not correct. If you have linux-lts & linux installed, linux-lts is detected as more recent than linux. Additional info: * package version(s) * config and/or log files etc. Package version: grub2-common 1:1.99-6 Steps to reproduce: Install linux & linux-lts package, run grub-mkconfig. Attached a patch which permits to detect them in the correct order (inspired from one of the Fedora bugtracker) |
This task depends upon
Closed by Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:13 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/p ackaging/packages/grub/issues/1
Saturday, 25 November 2023, 20:13 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/p ackaging/packages/grub/issues/1
1) Kernel naming is a distribution choice, there is no universal right answer here. In fact, archlinux deviates from upstream norm.
2) Given archlinux rolling release philosophy, it stands to reason that if a user has both linux and linux-lts installed, linux should be pushed as the default. Let user configuration drive changes from this norm rather than relying on grub parsing to guess.
Three real options here:
1) Revamp arch implementation to make use of GRUB_DEFAULT, configuring IDs a bit differently
2) Apply patch from upstream #4259 or something akin to reporter here, acknowledging that an alpha sorted listing doesn't serve much more than solving for the current core repository kernels. touch /boot/vmlinuz-zzz and suddenly there's a new priority.
3) Refactor 10_linux so that the distribution preferred kernel is made first if available.
Attached is a hack for route 3 which I have verified.
I'll file up with an upstream tag on this new direction, but hold that this issue is a distribution bug which could be served in time by an upstream feature.
My GRUB version is: 1:2.02.rc2-1 which I assume means 2.02.rc2-1
The default Arch Linux installation doesn't pull 'linux-lts'.
If a user installs linux-lts manually, it's assumed that the user wants to boot linux-lts and grub-mkconfig does that.
I completely see what you're saying; however, I need the "GRUB_DEFAULT" line set to "saved" or the "grub-reboot" command does not work correctly. I do understand though that not many people are probably using this command.
Most user install linux-lts as fallback just incase linux boot fails.
Plus arch philosophy is of always being up-to-date with latest version and hence having linux should be the preferred kernel.
Using the pristine mkconfig_lib config file I always ended with lts on top of linux, which isn't a good deal since I would like to have those in the opposite order.
It's nice to say that on current arch versions, grub-mkconfig_lib is now located on /usr/share/grub/ and no more on /usr/lib/grub/ as shown on the proposed patch.
Here's my cent over this issue: a new patch file (I keep the original content commented in case anyone want to check on it).
Thanks to everyone involved on this. Cheers!
LGTM!
---
Edit:
After reviewing my options and reading a bit about grub (https://www.dedoimedo.com/computers/grub-2.html),
I decided against modifying grub specific files. I think it's better to modify your /etc/grub.d/10_linux script.
Around line 198 in the script, I found:
linux=`version_find_latest $list`
Using the currently popular suggestion in this thread, I changed the line to:
linux=`echo $list | tr ' ' '\n' | sort -V | head -1 | cat`
And that seems to have worked!
I think this approach of modifying the script may actually be a better approach, than changing the way grub orders kernels because of Arch-specific naming conventions.
please edit `/etc/grub.d/10_linux. according to the patch or directly apply it.
No need to flood with comments. If something agan not working then may be `pacman`
replaces `/etc/grub.d/10_linux` with a new file. just apply it again. I'm still using the
same with success.
```patch
diff --git a/etc/grub.d/10_linux b/10_linux
index 81c8415..22402c3 100755
--- a/etc/grub.d/10_linux
+++ b/10_linux
@@ -197,7 +197,16 @@ submenu_indentation=""
is_top_level=true
while [ "x$list" != "x" ] ; do
- linux=`version_find_latest $list`
+ # linux=`version_find_latest $list`
+
+ # If you want `linux` should boot by default and `linux-lts`
+ # is fallback, uncomment below line. You can use differnet
+ # sorting technique to change sorting behaviour, see `man sort`
+ # For more, see at https://bugs.archlinux.org/task/28081 on archive.org
+
+ # linux=`echo $list | tr ' ' '\n' | sort -V | head -1 | cat`
+ linux=`echo $list | tr ' ' '\n' | sort -Vr | head -1 | cat`
+
gettext_printf "Found linux image: %s\n" "$linux" >&2
basename=`basename $linux`
dirname=`dirname $linux`
```