Issues with grub-menu and booting into a specific kernel

Hi,

Since my kernel got upgraded to 5.18.10 I started encountering many bugs on my 2013 macbook air which is my main laptop at home. There are graphical glitches, I lost wi-fi connection and camera stopped working. Everything works correctly on kernel kernel-5.17.9-300.fc36.x86_64

Now, I would like to make that kernel the default kernel that computer automatically boots to. I have computer users at home who are a not tech-savvy & don’t know what grub boot menu is or which kernel to choose.

I followed multiple guidelines. First i deleted the newer kernel and locked the current kernel. Below you can find commands I used:

$ sudo dnf install ‘dnf-command(versionlock)’
$ sudo dnf versionlock add kernel-5.17.9-300.fc36.x86_64
$ sudo dnf remove kernel-5.18.9-200.fc36.x86_64

After that I fixed the wifi issue on my Broadcom Chip by following this guideline:
https://fedoraproject.org/wiki/Common_F30_bugs#broadcom-wl-mesh

Unfortunately following it reinstalled the version of the kernel that I previously deleted. Good news is that wifi works on all kernel versions now. What I would ultimately like to do is to:

  1. Configure grub so it automatically boots to the correct kernel
  2. Delete other unused kernel versions (if it won’t break the wifi again)

I already know how to do #2 but I am not sure how to go about step 1 mentioned above. I followed multiple tutorials and none of them seems to be producing satisfying results. I used grubby, edited /etc/default/grub and did a couple other things… Would someone be willing to help me with that?

Current output:
[asti@fedora ~]$ rpm -q kernel
kernel-5.17.9-300.fc36.x86_64
[asti@fedora ~]$ uname -sr
Linux 5.17.9-300.fc36.x86_64

Yet my boot-menu still shows 3 different kernels and boots automatically to the newer one that is highlighted first. I am still a newbie when it comes to Fedora (been using Linux for 2 years now) and Engiish is my second language, so I am sorry if I made any mistakes in this description.

Kind regards,

Hi and welcome to the Fedora community! :slight_smile:

Have u checked out:

https://docs.fedoraproject.org/en-US/quick-docs/kernel/booting/

https://docs.fedoraproject.org/en-US/fedora/rawhide/system-administrators-guide/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader/

I know for a newbie it may be really overwhelming. But I hope these links may help and solve your issue!

v/r

Andi/andilinux

Hi Andi and thank you for your fast reply! :slight_smile:

I was able to set default kernel for the one that I wanted:

sudo ls /boot | grep vmlinuz
vmlinuz-0-rescue-ebaa0596d56645bd9b367efd1087575e
vmlinuz-5.17.9-300.fc36.x86_64
vmlinuz-5.18.10-200.fc36.x86_64
vmlinuz-5.18.9-200.fc36.x86_64
[asti@fedora~]$ sudo grubby --set-default /boot/vmlinuz-5.17.9-300.fc36.x86_64
[asti@fedora ~]$ sudo grubby --default-kernel
/boot/vmlinuz-5.17.9-300.fc36.x86_64
[asti@fedora ~]$ sudo grubby --default-index
2

But unfortunately how editing grub-menu entries works is really unclear to me even after reading the instruction :frowning:

After a reboot system still boots up to the newest kernel release highlighted which is:
5.18.10-200.fc36.x86_64

Would anybody be so nice and help me with that?

Kind regards,

1 Like

This might answer your question about how to save the last chosen grub entry:

Specifically, edit /etc/default/grub like this

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

And then run

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

You’ll have to choose your kernel manually the first time, but as long as the above steps worked, grub should remember your choice thereafter.

Hi!

I edited /etc/default/grub and right now it looks like this:

GNU nano 6.0 /etc/default/grub
GRUB_TIMEOUT=“5”
GRUB_DISTRIBUTOR=“$(sed ‘s, release .*$,g’ /etc/system-release)”
GRUB_DEFAULT=“saved”
GRUB_SAVEDEFAULT=“true”
GRUB_DISABLE_SUBMENU=“true”
GRUB_TERMINAL_OUTPUT=“console”
GRUB_CMDLINE_LINUX=“rhgb quiet”
GRUB_DISABLE_RECOVERY=“true”
GRUB_ENABLE_BLSCFG=“true”

Than:
[asti@fedora ~]$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found Mac OS X on /dev/sda1
Adding boot menu entry for UEFI Firmware Settings …
done

After a reboot, I clicked on the correct, older version of the kernel and than after short use rebooted again. The grub-menu still pops-up and system boots to the first highlighted kernel which is 5.18.10. So nothing changed… :frowning:

run this, and then reboot, you shouldn’t need to regenerate the configuration for this to work.

You will need to do
This each time kernel is updated.

If it doesn’t work can you post
sudo grubby --info=ALL

You may also want to have a look at, Howto prevent kernel updates?

1 Like

Maybe I am missing something obvious? I already used that command (as described in my second post) and nothing changed. The boot-menu still shows up and the first highlighted kernel (which is 5.18.10) is booting if I don’t do anything. So it doesn’t seem to work.

Grubby info below:

[asti@fedora ~]$ sudo grubby --info=ALL
index=0
kernel=“/boot/vmlinuz-5.18.10-200.fc36.x86_64”
args=“ro rootflags=subvol=root rhgb quiet”
root=“UUID=e4d6761d-f425-448d-af14-99a819259fe1”
initrd=“/boot/initramfs-5.18.10-200.fc36.x86_64.img”
title=“Fedora Linux (5.18.10-200.fc36.x86_64) 36 (Xfce)”
id=“ebaa0596d56645bd9b367efd1087575e-5.18.10-200.fc36.x86_64”
index=1
kernel=“/boot/vmlinuz-5.18.9-200.fc36.x86_64”
args=“ro rootflags=subvol=root rhgb quiet”
root=“UUID=e4d6761d-f425-448d-af14-99a819259fe1”
initrd=“/boot/initramfs-5.18.9-200.fc36.x86_64.img”
title=“Fedora Linux (5.18.9-200.fc36.x86_64) 36 (Xfce)”
id=“ebaa0596d56645bd9b367efd1087575e-5.18.9-200.fc36.x86_64”
index=2
kernel=“/boot/vmlinuz-5.17.9-300.fc36.x86_64”
args=“ro rootflags=subvol=root rhgb quiet”
root=“UUID=e4d6761d-f425-448d-af14-99a819259fe1”
initrd=“/boot/initramfs-5.17.9-300.fc36.x86_64.img”
title=“Fedora Linux (5.17.9-300.fc36.x86_64) 36 (Xfce)”
id=“ebaa0596d56645bd9b367efd1087575e-5.17.9-300.fc36.x86_64”
index=3
kernel=“/boot/vmlinuz-0-rescue-ebaa0596d56645bd9b367efd1087575e”
args=“ro rootflags=subvol=root rhgb quiet”
root=“UUID=e4d6761d-f425-448d-af14-99a819259fe1”
initrd=“/boot/initramfs-0-rescue-ebaa0596d56645bd9b367efd1087575e.img”
title=“Fedora Linux (0-rescue-ebaa0596d56645bd9b367efd1087575e) 36 (Xfce)”
id=“ebaa0596d56645bd9b367efd1087575e-0-rescue”

can you do:
sudo grubby --set-default /boot/vmlinuz-5.17.9-300.fc36.x86_64

followed by:
sudo grub2-editenv list

The saved entry should reflect the change.

It should be the same post reboot.

Could you also check:
ls -lR /boot/

Here’s the output. Some stuff that is showing in terminal is in Polish. Rebooting soon.
EDIT: Same behaviour after reboot. Maybe I should edit grub-menu so it times out after 0 seconds? Maybe that will lead to loading correct kernel automatically?

[asti@fedora ~]$ sudo grubby --set-default /boot/vmlinuz-5.17.9-300.fc36.x86_64
The default is /boot/loader/entries/ebaa0596d56645bd9b367efd1087575e-5.17.9-300.fc36.x86_64.conf with index 2 and kernel /boot/vmlinuz-5.17.9-300.fc36.x86_64
[asti@fedora ~]$ sudo grub2-editenv list
saved_entry=ebaa0596d56645bd9b367efd1087575e-5.17.9-300.fc36.x86_64
boot_success=1
boot_indeterminate=0
save_default=true
[asti@fedora ~]$ ls -lR /boot/
/boot/:
razem 244896
-rw-r–r–. 1 root root 244012 05-18 17:26 config-5.17.9-300.fc36.x86_64
-rw-r–r–. 1 root root 247301 07-07 19:39 config-5.18.10-200.fc36.x86_64
-rw-r–r–. 1 root root 247299 07-02 18:14 config-5.18.9-200.fc36.x86_64
drwx------. 1 root root 7 05-27 18:38 efi
drwxr-xr-x. 2 root root 4096 05-04 23:30 extlinux
drwx------. 3 root root 4096 07-14 10:09 grub2
-rw-------. 1 root root 103802608 05-27 18:40 initramfs-0-rescue-ebaa0596d56645bd9b367efd1087575e.img
-rw-------. 1 root root 21982750 05-27 20:23 initramfs-5.17.9-300.fc36.x86_64.img
-rw-------. 1 root root 35235125 07-13 16:29 initramfs-5.18.10-200.fc36.x86_64.img
-rw-------. 1 root root 22722808 07-08 08:07 initramfs-5.18.9-200.fc36.x86_64.img
drwxr-xr-x. 3 root root 4096 05-27 18:38 loader
drwx------. 2 root root 16384 05-27 18:32 lost+found
lrwxrwxrwx. 1 root root 46 05-27 20:22 symvers-5.17.9-300.fc36.x86_64.gz → /lib/modules/5.17.9-300.fc36.x86_64/symvers.gz
lrwxrwxrwx. 1 root root 47 07-13 16:28 symvers-5.18.10-200.fc36.x86_64.gz → /lib/modules/5.18.10-200.fc36.x86_64/symvers.gz
lrwxrwxrwx. 1 root root 46 07-08 08:06 symvers-5.18.9-200.fc36.x86_64.gz → /lib/modules/5.18.9-200.fc36.x86_64/symvers.gz
-rw-------. 1 root root 6235514 05-18 17:26 System.map-5.17.9-300.fc36.x86_64
-rw-------. 1 root root 6253593 07-07 19:39 System.map-5.18.10-200.fc36.x86_64
-rw-------. 1 root root 6253454 07-02 18:14 System.map-5.18.9-200.fc36.x86_64
-rwxr-xr-x. 1 root root 11802352 05-27 18:39 vmlinuz-0-rescue-ebaa0596d56645bd9b367efd1087575e
-rwxr-xr-x. 1 root root 11802608 05-18 17:26 vmlinuz-5.17.9-300.fc36.x86_64
-rwxr-xr-x. 1 root root 11939888 07-07 19:39 vmlinuz-5.18.10-200.fc36.x86_64
-rwxr-xr-x. 1 root root 11941872 07-02 18:14 vmlinuz-5.18.9-200.fc36.x86_64
ls: nie można otworzyć katalogu ‘/boot/efi’: Brak dostępu

/boot/extlinux:
razem 1100
-rw-r–r–. 1 root root 1780 01-27 18:35 cat.c32
-rw-r–r–. 1 root root 25172 01-27 18:35 chain.c32
-rw-r–r–. 1 root root 1420 01-27 18:35 cmd.c32
-rw-r–r–. 1 root root 3844 01-27 18:35 cmenu.c32
-rw-r–r–. 1 root root 1656 01-27 18:35 config.c32
-rw-r–r–. 1 root root 4536 01-27 18:35 cptime.c32
-rw-r–r–. 1 root root 4680 01-27 18:35 cpu.c32
-rw-r–r–. 1 root root 1940 01-27 18:35 cpuid.c32
-rw-r–r–. 1 root root 2940 01-27 18:35 cpuidtest.c32
-rw-r–r–. 1 root root 1760 01-27 18:35 debug.c32
-rw-r–r–. 1 root root 4256 01-27 18:35 dhcp.c32
-rw-r–r–. 1 root root 3132 01-27 18:35 dir.c32
-rw-r–r–. 1 root root 2192 01-27 18:35 disk.c32
-rw-r–r–. 1 root root 8936 01-27 18:35 dmi.c32
-rw-r–r–. 1 root root 12512 01-27 18:35 dmitest.c32
-rw-r–r–. 1 root root 3452 01-27 18:35 elf.c32
-rw-r–r–. 1 root root 2920 01-27 18:35 ethersel.c32
-rw-r–r–. 1 root root 10372 01-27 18:35 gfxboot.c32
-rw-r–r–. 1 root root 1764 01-27 18:35 gpxecmd.c32
-rw-r–r–. 1 root root 165004 01-27 18:35 hdt.c32
-rw-r–r–. 1 root root 3896 01-27 18:35 hexdump.c32
-rw-r–r–. 1 root root 2008 01-27 18:35 host.c32
-rw-r–r–. 1 root root 1968 01-27 18:35 ifcpu64.c32
-rw-r–r–. 1 root root 4288 01-27 18:35 ifcpu.c32
-rw-r–r–. 1 root root 4480 01-27 18:35 ifmemdsk.c32
-rw-r–r–. 1 root root 2092 01-27 18:35 ifplop.c32
-rw-r–r–. 1 root root 1840 01-27 18:35 kbdmap.c32
-rw-r–r–. 1 root root 5052 01-27 18:35 kontron_wdt.c32
-rw-r–r–. 1 root root 116156 01-27 18:35 ldlinux.c32
-rw-r–r–. 1 root root 5260 01-27 18:35 lfs.c32
-rw-r–r–. 1 root root 179932 01-27 18:35 libcom32.c32
-rw-r–r–. 1 root root 68016 01-27 18:35 libgpl.c32
-rw-r–r–. 1 root root 101924 01-27 18:35 liblua.c32
-rw-r–r–. 1 root root 24260 01-27 18:35 libmenu.c32
-rw-r–r–. 1 root root 24208 01-27 18:35 libutil.c32
-rw-r–r–. 1 root root 4876 01-27 18:35 linux.c32
-rw-r–r–. 1 root root 3136 01-27 18:35 ls.c32
-rw-r–r–. 1 root root 7140 01-27 18:35 lua.c32
-rw-r–r–. 1 root root 11232 01-27 18:35 mboot.c32
-rw-r–r–. 1 root root 26140 01-27 18:35 memdisk
-rw-r–r–. 1 root root 2648 01-27 18:35 meminfo.c32
-rw-r–r–. 1 root root 26240 01-27 18:35 menu.c32
-rw-r–r–. 1 root root 3576 01-27 18:35 pci.c32
-rw-r–r–. 1 root root 3676 01-27 18:35 pcitest.c32
-rw-r–r–. 1 root root 3184 01-27 18:35 pmload.c32
-rw-r–r–. 1 root root 1836 01-27 18:35 poweroff.c32
-rw-r–r–. 1 root root 3288 01-27 18:35 prdhcp.c32
-rw-r–r–. 1 root root 1668 01-27 18:35 pwd.c32
-rw-r–r–. 1 root root 12524 01-27 18:35 pxechn.c32
-rw-r–r–. 1 root root 1544 01-27 18:35 reboot.c32
-rw-r–r–. 1 root root 14052 01-27 18:35 rosh.c32
-rw-r–r–. 1 root root 1800 01-27 18:35 sanboot.c32
-rw-r–r–. 1 root root 3216 01-27 18:35 sdi.c32
-rw-r–r–. 1 root root 14780 01-27 18:35 sysdump.c32
-rw-r–r–. 1 root root 9056 01-27 18:35 syslinux.c32
-rw-r–r–. 1 root root 3152 01-27 18:35 vesa.c32
-rw-r–r–. 1 root root 2364 01-27 18:35 vesainfo.c32
-rw-r–r–. 1 root root 26756 01-27 18:35 vesamenu.c32
-rw-r–r–. 1 root root 2032 01-27 18:35 vpdtest.c32
-rw-r–r–. 1 root root 2720 01-27 18:35 whichsys.c32
-rw-r–r–. 1 root root 3744 01-27 18:35 zzjson.c32
ls: nie można otworzyć katalogu ‘/boot/grub2’: Brak dostępu

/boot/loader:
razem 4
drwx------. 2 root root 4096 07-14 08:18 entries
ls: nie można otworzyć katalogu ‘/boot/loader/entries’: Brak dostępu
ls: nie można otworzyć katalogu ‘/boot/lost+found’: Brak dostępu

sorry this is my fault, I forgot to sudo.

sudo ls -lR /boot/efi
sudo ls -lR /boot/grub2
sudo ls -lR /boot/loader

Is this machine dual booting anything?

Thanks

This is a Macbook so maybe there’s an OSX recovery partition left there, but I am quite sure I formatted the whole SSD when I was installing linux. Output from commands below:

[asti@fedora ~]$ sudo ls -lR /boot/efi
[sudo] hasło użytkownika asti:
/boot/efi:
razem 4
drwxr-xr-x. 1 root root 4 01-20 02:44 EFI
-rw-r–r–. 1 root root 34 01-20 19:42 mach_kernel
drwxr-xr-x. 1 root root 3 01-20 19:42 System

/boot/efi/EFI:
razem 0
drwx------. 1 root root 6 07-13 16:40 BOOT
drwx------. 1 root root 16 07-13 16:40 fedora

/boot/efi/EFI/BOOT:
razem 1820
-rwx------. 1 root root 742064 06-15 18:38 BOOTIA32.EFI
-rwx------. 1 root root 946712 06-15 18:38 BOOTX64.EFI
-rwx------. 1 root root 70776 06-15 18:38 fbia32.efi
-rwx------. 1 root root 90280 06-15 18:38 fbx64.efi

/boot/efi/EFI/fedora:
razem 12480
-rwx------. 1 root root 112 06-15 18:38 BOOTIA32.CSV
-rwx------. 1 root root 110 06-15 18:38 BOOTX64.CSV
-rwx------. 1 root root 1660168 06-07 19:16 gcdia32.efi
-rwx------. 1 root root 2622728 06-07 19:16 gcdx64.efi
-rw-r–r–. 1 root root 6843 07-13 16:40 grub.cfg
-rwx------. 1 root root 1660168 06-07 19:16 grubia32.efi
-rwx------. 1 root root 2622728 06-07 19:16 grubx64.efi
-rwx------. 1 root root 678576 06-15 18:38 mmia32.efi
-rwx------. 1 root root 857248 06-15 18:38 mmx64.efi
-rwx------. 1 root root 946712 06-15 18:38 shim.efi
-rwx------. 1 root root 742064 06-15 18:38 shimia32.efi
-rwx------. 1 root root 946712 06-15 18:38 shimx64.efi
drwxr-xr-x. 1 root root 2 07-13 16:40 themes

/boot/efi/EFI/fedora/themes:
razem 0

/boot/efi/System:
razem 0
drwxr-xr-x. 1 root root 3 01-20 19:42 Library

/boot/efi/System/Library:
razem 0
drwxr-xr-x. 1 root root 5 05-27 18:41 CoreServices

/boot/efi/System/Library/CoreServices:
razem 2560
lrwxrwxrwx. 1 root root 28 05-27 18:41 boot.cfg → …/…/…/EFI/fedora/grub.cfg
-rwx------. 1 root root 2610440 03-25 21:37 boot.efi
-rw-r–r–. 1 root root 384 01-20 19:42 SystemVersion.plist
[asti@fedora ~]$ sudo ls -lR /boot/grub2
/boot/grub2:
razem 16
drwx------. 2 root root 4096 07-13 16:40 fonts
-rw-------. 1 root root 6843 07-14 08:18 grub.cfg
-rw-------. 1 root root 1024 07-15 16:03 grubenv

/boot/grub2/fonts:
razem 2340
-rwx------. 1 root root 2394108 06-07 19:16 unicode.pf2
[asti@fedora ~]$ sudo ls -lR /boot/loader
/boot/loader:
razem 4
drwx------. 2 root root 4096 07-14 08:18 entries

/boot/loader/entries:
razem 16
-rw-r–r–. 1 root root 401 07-14 08:18 ebaa0596d56645bd9b367efd1087575e-0-rescue.conf
-rw-r–r–. 1 root root 325 07-14 08:18 ebaa0596d56645bd9b367efd1087575e-5.17.9-300.fc36.x86_64.conf
-rw-r–r–. 1 root root 329 07-14 08:18 ebaa0596d56645bd9b367efd1087575e-5.18.10-200.fc36.x86_64.conf
-rw-r–r–. 1 root root 325 07-14 08:18 ebaa0596d56645bd9b367efd1087575e-5.18.9-200.fc36.x86_64.conf

This looks suspicious. and has obviously been altered on 07/13.

On mine that file shows this
-rwx------. 1 root root 143 Oct 4 2021 grub.cfg
This shows instructions that may fix the issue
https://fedoraproject.org/wiki/GRUB_2#Instructions_for_UEFI-based_systems

This is another guide.
https://docs.fedoraproject.org/en-US/fedora/latest/system-administrators-guide/kernel-module-driver-configuration/Working_with_the_GRUB_2_Boot_Loader/

Since the release of fedora 34 the primary grub.cfg file has resided at /boot/grub2/grub.cfg and the file at /boot/efi/EFI/fedora/grub.cfg has been a pointer that redirects grub on those systems to the other file. Replacing the one under /boot/efi causes problems.

2 Likes

Thank you for this suggestion!

I followed these instructions: GRUB 2 - Fedora Project Wiki and after doing that, the system seems to automatically pick the last option I have chosen in grub. So if I choose the correct kernel, it comes back to it and highlights it after a reboot. If I choose newer kernel, than it automatically highlights this kernel after a reboot. Is that the correct type of behaviour?

Is there a way to delete all other kernels from grub just to make sure none of my family members messes things up? I tried to do that before following the tutorials but didn’t suceeed. :frowning:

Kind regards,

You really do not want to do that (although you can).
Fedora by default only keeps 3 installed kernels and that is so that if a new kernel update breaks the system the user can boot to the earlier kernel for recovery. It also requires a minimum of 2 kernels – the one booted from at time of update and the newly installed one. The rescue kernel should never be selected by default.

The best way is to tell them to let the system boot automatically from power on and it will boot properly. Also tell them if they select a different kernel in the grub menu it may not boot properly.

They should be able to learn that a few moments wait during boot is better than breaking the system. You might also suggest they power on then walk away until the login screen appears.

If you really, really want to remove an installed kernel the command is sudo dnf remove kernel*VERSION where you would replace VERSION with something like ‘5.18.5’ or similar for whichever kernel you want to remove. Dnf should refuse to remove the currently booted kernel.

You also can edit /etc/dnf/dnf.conf and change the line installonly_limit=3 to installonly_limit=2 if you only want to keep the kernel you are currently booted from and the latest being installed.

Yes

2 Likes

Thank you so much! That is super helpful! I think we can consider this topic to be closed. I am happy I found such a kind Linux community here :slight_smile:

Please mark the post you consider as the solution.