Summary: | sys-boot/grub-2.12-r2: grub-mkconfig generates a config listing old kernels before just installed ones | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Pacho Ramos <pacho> |
Component: | Current packages | Assignee: | Mike Gilbert <floppym> |
Status: | RESOLVED UPSTREAM | ||
Severity: | normal | CC: | base-system, pacho |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
Generated grub.cfg
/etc/default/grub |
Description
Pacho Ramos
2024-03-10 12:41:35 UTC
Created attachment 887249 [details]
Generated grub.cfg
Created attachment 887250 [details]
/etc/default/grub
The order is determined by piping the *full path* for each kernel image through the "version_sort" function with the 'r" (reverse) flag. https://git.savannah.gnu.org/cgit/grub.git/tree/util/grub.d/10_linux.in?h=grub-2.12#n201 version_sort just calls "sort -V -r". https://git.savannah.gnu.org/cgit/grub.git/tree/util/grub-mkconfig_lib.in?h=grub-2.12#n203 The letter "k" comes before the letter "v", so "vmlinuz" gets sorted after "kernel", and then gets moved to the top in reverse order. If you want to see an improvement here, please send a patch upstream. Do you know why they have this complex algorithm for sorting? I see it was even updated for the 2.12 version. On the other hand, the much simpler one used for NetBSD would simply work (util/grub.d/10_netbsd.in), as it simply relies on "ls -t" for the sorting. I have also seen that other distributions rely on different sorting tools (but we cannot rely on them as they are for RPM distros). I wonder then about other reasons that I don't know for upstream wanting this behavior... even if I can see some old posts in multiple distribution forums with users hitting similar issues with the ordering. (In reply to Pacho Ramos from comment #4) The algorithm isn't really that complex. It sorts based on file name. Using ls -t would sort based on modification time instead. I don't know of any reason to prefer one method over the other. I suspect 10_linux and 10_netbsd use different sorting methods simply because they were written by different people. Relevant commits: Switch from random order to sorted by name for Linux https://git.savannah.gnu.org/cgit/grub.git/commit/?id=57f9639766e7e40a796b2df06591942b6fdaa7b4 NetBSD support added https://git.savannah.gnu.org/cgit/grub.git/commit/?id=0d2c20c6f15ec8c7bcc1e7f30c7f9e0f561deb2f Optimized sorting for Linux https://git.savannah.gnu.org/cgit/grub.git/commit/?id=99e05ab555f013b5ce45a3fd04f8ccd5f4e5bf95 (In reply to Mike Gilbert from comment #5) > (In reply to Pacho Ramos from comment #4) > I don't know of any reason to prefer one method over the other. Well, the advantage of ensuring that the latest installed kernel is used is that I think it is what most of us expect to happen just after compiling and installing an updated kernel. For example, I remember that I hit a similar issue when installing a Gentoo machine from the Gentoo Live DVD. I was surprised about why I was still having some drivers for the mouse not working even if I was adding the support for it. At the end, I realized that the original non-changed kernel was still being used by default at boot time. |