You are not logged in.

#1 2021-05-22 16:39:38

Kobrakai
Member
Registered: 2021-05-22
Posts: 14

[SOLVED] GRUB boots into LTS kernel instead of latest

I have both the linux and linux-lts kernels installed and I want to boot into the latest kernel by default, but when I select Arch Linux from GRUB it always boots the LTS kernel. The only way to boot the latest kernel is by selecting it from the advanced options sub-menu in GRUB.

I have read the arch wiki, in particular the section that addresses this specific problem:
https://wiki.archlinux.org/title/GRUB/T … le_entries

This says that I can change it by disabling the advanced options sub-menu in the GRUB config and setting GRUB_DEFAULT which I'm sure will work, except I don't want to disable the sub menu. I have other operating systems installed and I want to keep it clean with a simple list where I can just select 'Arch Linux' and it boots the latest kernel automatically.

The other suggestion on the wiki is to enable GRUB_SAVEDEFAULT but I don't want to do this because I sometimes boot into other operating systems. I want arch to always be the default otherwise I forget to change it back and boot into the wrong operating system which is annoying.

I thought the most recently installed kernel would take precedence so I tried uninstalling and installing the latest kernel and re-generating GRUB but it still boots into the LTS kernel no matter what I do. SO my question is how is GRUB choosing the order of the kernels?

Last edited by Kobrakai (2021-06-06 17:55:28)

Offline

#2 2021-05-22 16:48:08

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,173

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

If you read two subheadings further you will see the mention of defining the default entry to boot from without any other intelligence: https://wiki.archlinux.org/title/GRUB/T … menu_entry

As for how it defines that without explicitly setting something the scripts in /etc/grub.d/ are what will be executed by grub-mkconfig to generate a config.

Last edited by V1del (2021-05-22 16:56:57)

Offline

#3 2021-05-22 16:55:57

Kobrakai
Member
Registered: 2021-05-22
Posts: 14

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

V1del wrote:

If you read just two subheadings further you will see the mention of defining the default entry to boot from wihtout any other intelligence: https://wiki.archlinux.org/title/GRUB/T … menu_entry

I tried setting it as "1>2" and it just selected the menu option for advanced options, although I just tried it again and waited the 5 seconds and it does actually boot into the latest kernel.

I would still like to know how GRUB decides on the order though, I haven't had this problem with other distributions so there must be a way to change it outside of GRUB.

Offline

#4 2021-05-23 20:43:21

Spinnekop
Member
Registered: 2018-02-16
Posts: 26

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

I also have the lts and the ck kernel installed and the option 'arch' in grub selects the lts. So I am also curious as to how grub-mkcong decides that the lts kernel should go first as per the OPs question. Changing the default or saved option does not actually answer the question.


Umuntu Ngumuntu Ngabantu
---------------------------------------
a person is a person through other people

Offline

#5 2021-05-23 20:51:35

Kobrakai
Member
Registered: 2021-05-22
Posts: 14

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

I found a solution to this earlier today. Basically you need to open this file:

/etc/grub.d/10_linux

Look for the line that says:

linux=`version_find_latest $list`

Replace it with this:

linux=`echo $list | tr ' ' '\n' | sort -V | head -1 | cat`

Then regenerate grub with:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Make a backup of the file just in case but it seems to be working for me now.

Offline

#6 2022-08-19 15:55:59

Kobrakai
Member
Registered: 2021-05-22
Posts: 14

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

Since the latest update to Grub the line in the above fix no longer exists in /etc/grub.d/10_linux. To fix this now change the following line:

reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -r | sed -e 's/ 1$/.old/; s/ 2$//')

To this:

reverse_sorted_list=$(echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | version_sort -V | sed -e 's/ 1$/.old/; s/ 2$//')

Then regenerate grub with:

sudo grub-mkconfig -o /boot/grub/grub.cfg

Offline

#7 2022-10-05 19:37:44

baszdmeg
Member
Registered: 2021-09-29
Posts: 2

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

Thanks. Works for me after updating grub.

Offline

#8 2022-10-05 22:07:54

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] GRUB boots into LTS kernel instead of latest

Closing this old solved thread.

Offline

Board footer

Powered by FluxBB