Biosias / uefi-mkconfig

grub-mkconfig inspired script for automatically managing uefi entries for booting linux kernel directly without bootloader
Apache License 2.0
7 stars 3 forks source link

Ignore -old versions of gentoo kernel #5

Closed skarekrow closed 2 months ago

skarekrow commented 2 months ago

Hello!

Love the project. So the issue I'm hitting is when I reconfigure an existing kernel (emerge --ask --config sys-kernel/gentoo-kernel-bin for instance) I will get a bunch of old files in that directory:

/efi/EFI/Gentoo # ls
config-6.6.32-gentoo-dist         initramfs-6.6.32-gentoo-dist.img.old  vmlinuz-6.6.32-gentoo-dist.efi
config-6.6.32-gentoo-dist.old     System.map-6.6.32-gentoo-dist         vmlinuz-6.6.32-gentoo-dist-old.efi
initramfs-6.6.32-gentoo-dist.img  System.map-6.6.32-gentoo-dist.old

Which uefi-mkconfig sees as valid kernels and will create an entry for them (correct so far):

 * Updating UEFI configuration...
 * Running uefi-mkconfig...
 * Warning, using kernel commands from "/proc/cmdline"!
 * Warning, kernel command "root=" is missing from loaded configuration!
 * Existing UEFI Entry "0100" for "/efi/EFI/Gentoo/vmlinuz-6.6.32-gentoo-dist.efi" from partition "nvme0n1p1" has been found.
 * Creating UEFI entry "0101" for "/efi/EFI/Gentoo/vmlinuz-6.6.32-gentoo-dist-old.efi" found on "nvme0n1p1"...

The issue that ends up happening is it then sets the next boot to use that old kernel, which is not the expected or wanted behavior. I would expect it to prefer and use the most current kernel.

efibootmgr
BootCurrent: 0100
Timeout: 1 seconds
BootOrder: 0101,0100
Boot0100* 6.6.32-gentoo-dist    HD(1,GPT,UUID,0x800,0x200000)/File(\EFI\Gentoo\vmlinuz-6.6.32-gen
too-dist.efi)--snip--
Boot0101* 6.6.32-gentoo-dist-old        HD(1,GPT,UUID,0x800,0x200000)/File(\EFI\Gentoo\vmlinuz-6.
6.32-gentoo-dist-old.efi)-- snip --

Hopefully this behavior can be tuned? I may have missed a config knob or something.

Thanks!

AndrewAmmerlaan commented 2 months ago

The issue that ends up happening is it then sets the next boot to use that old kernel, which is not the expected or wanted behavior. I would expect it to prefer and use the most current kernel.

I have not yet looked at it in detail, but this sounds like it is either a sorting problem. Or the issue is that the entry for x already exists, while the entry for x.old is new and therefore ends up earlier in the boot order. Perhaps it would make sense to explicitly set the boot order to uefi-mkconfig's internal sorting order?

Biosias commented 2 months ago

Hello there, glad to hear you like the script.

This is for sure a sorting problem. This has become something of a nemesis of mine on this project.

The problem is that the script sorts the kernels in a wrong way so that the "old" kernel entries are created last. This is wrong. efibootmgr which we use to add the entries, works in a way that means "Last added entry = First place in bootorder".

So fix for this will be in theory very simple. I'll make sure "old" kernel entries are always added first.

Biosias commented 2 months ago

Thank you for pointing this out! This was an oversight on my part when creating the new sorting system in 1.5 I think

Biosias commented 2 months ago

@AndrewAmmerlaan can I ask you for your opinion regarding #6 ?

Biosias commented 2 months ago

Hello @skarekrow ,

just wanted to let you know that I've found and fixed the issue you have reported. It will be out with the new version of uefi-mkconfig. I just need to finish few more changes and tests before releasing it.

If you want we can leave this issue opened until it is released or we can close it now and if some further problems appear you can open a new one. The choice is on you.

skarekrow commented 2 months ago

We can close this since the PR is merged. Thanks @Biosias!