Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Set Grub default to newest kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Jim5678
n00b
n00b


Joined: 23 Jan 2024
Posts: 13

PostPosted: Tue Oct 22, 2024 11:48 am    Post subject: Set Grub default to newest kernel Reply with quote

Hello,
Is there a way to set the default kernel grub uses to the most recently installed kernel. I'm building my kernels manually and installing using
Code:

genkernel --install initramfs --mdadm
grub-mkconfig -o /boot/grub/grub.cfg
grub-install --efi-directory=/efi


Thanks
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2185

PostPosted: Tue Oct 22, 2024 3:43 pm    Post subject: Reply with quote

If you install your kernels to a /boot directory or filesystem, and that filesystem is ext4 or other Linux, you should be able to use a symbolic link to the current kernel. This won't work if you install your kernels to a directory in the EFI partition, as that's a Microsoft filesystem that don't support symbolic links.

The original installkernel script handled the case where there is an existing "vmlinuz" symbolic link to "vmlinuz-6.11.5" or whatever, together with similar symbolic links for "config" and "System.map". For compatibility, if there was no existing symbolic link, it wouldn't create one, but otherwise it would peform a pirouette to maintain "vmlinuz", "vmlinuz.old" and so forth links to the versions currently and most previously installed. The relatively new Gentoo version of installkernel can, I think, still work this way, depending on USE flags.

That said, I don't use genkernel, so I've no idea if it can do the same, but I'd hope so.
_________________
Greybeard
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 668

PostPosted: Tue Oct 22, 2024 4:33 pm    Post subject: Reply with quote

Goverp wrote:
...stuff...
Indeed.
If you are following the latest revision of the handbook for EFI boot, there is no need to "install" kernels at all, just symlink /boot/vmlinuz{.old} et al to bzimage etc. in the respective source trees.
Also, why are we using compressed kernels when space is at such a low premium nowadays?
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2185

PostPosted: Tue Oct 22, 2024 5:01 pm    Post subject: Reply with quote

Ralphred wrote:
...If you are following the latest revision of the handbook for EFI boot, there is no need to "install" kernels at all, just symlink /boot/vmlinuz{.old} et al to bzimage etc. in the respective source trees. ...

That's neat, but if you discover your latest and greatest kernel is broken, you need a way to get at the previous working one - or maybe keep a recovery "disk" to hand.
FWIW, I've just found kernel 6.11.4 won't boot on my laptop with its hard drive replaced by an SSD. 6.11.3 and 6.11.5 both fine, all three with the same .config. As soon as I found it wouldn't boot, back to "vmlinuz.old", already in my GRUB menu.
_________________
Greybeard
Back to top
View user's profile Send private message
no101
n00b
n00b


Joined: 10 Oct 2022
Posts: 14
Location: Piney Woods

PostPosted: Tue Oct 22, 2024 5:09 pm    Post subject: Reply with quote

https://wiki.gentoo.org/wiki/Kernel/Removal#Using_eclean-kernel

eclean-kernel is awsome. Not only does it clean stale entries from /boot, it also regenerates grub.
Back to top
View user's profile Send private message
Ralphred
l33t
l33t


Joined: 31 Dec 2013
Posts: 668

PostPosted: Tue Oct 22, 2024 5:51 pm    Post subject: Reply with quote

Goverp wrote:
As soon as I found it wouldn't boot, back to "vmlinuz.old", already in my GRUB menu.
Well, technically if I bothered to "do it the way mentioned" vmlinuz.old would point to bzimage in 6.8.2's source tree, so a "backup" would still exist.
n101 wrote:
it also regenerates grub.
I'm really "precious" about my grub.cfg files: I always run a grub-mkconfig >/dev/null to make sure it's got everything, and run a grub-mkconfig >/boot/grub/grub.cfg-[kernel version] before updating because I have semi-complicated menu entry generation. Letting something automate that process feels like letting a stranger use your kitchen to me...
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2185

PostPosted: Wed Oct 23, 2024 9:41 am    Post subject: Reply with quote

Ralphred wrote:
... and run a grub-mkconfig >/boot/grub/grub.cfg-[kernel version] before updating because I have semi-complicated menu entry generation. Letting something automate that process feels like letting a stranger use your kitchen to me...

Indeed. I haven't used the output from grub-mkconfig for years, and hardly ever change grub.cfg.
Back in the days of "GRUB legacy", i.e. version 1, you wrote your own grub.conf, and it was a one-time operation, unless you wanted to tweak your boot cmdline. Then GRUB 2 arrives, and to make things easier, they provide grub-mkconfig to provide an initial grub.cfg. So far, so good. Then Ubuntu (I don't know if it's actually their fault, but I might as well blame them) decide to stop using the vmlinuz symlinks, so now installing a kernel requires regenerating your grub.cfg. Madness.
_________________
Greybeard
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum