How to fix Kernel after a dnf installation

Greetings, I am new in Fedora (and Linux) and I’ve installed the f37 on a brand new laptop. Everything was running smoothly, I’ve been doing some dnf installation and updates, regular stuffs, but I needed to install the Virtualbox in order to use another linux distro (that I wasn’t able to install properly), but Virtualbox gave me an error when I’ve tried to run the Virtual Image of such distro:

The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing

‘/sbin/vboxconfig’

as root.

If your system has EFI Secure Boot enabled you may also need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system’s documentation for more information.

Then I’ve found a topic that it seems solving this issue, and so I’ve run those two lines:

sudo dnf -y install @development-tools
sudo dnf install kernel-headers kerlen-devel dkms -y

Now, the Virtualbox is successfully running the VM and the linux distro I wanted, but everything is broken. Graphical glitches, Wi-fi not recognized at all and so not able to connect to internet, overall instability, etc. I’ve basically messed up my OS just to solve a problem for a simple tool.

How can I fix this issue? Is there any solution to revert back to a previous version of the Kernel, or undo what I did? Keep in mind that the Wi-Fi is not working anymore, plus my laptop doesn’t have an Ethernet port. I cannot connect to internet basically. Thanks

Welcome to the Fedoraproject @joemw6

If you use the Gnome desktop alias the Workstation you have a tool included to virtualize a other os.
It is called Boxes. No need to install virtualbox.

If you use a spin, you can use the virtualization as described here:
https://virt-manager.org/
It is a bit more complex as Boxes but if you know Virtualbox you will get along with it.

If you use command in your terminal please take care of the -y parameter.

As you used it in the command mentioned.
Please use it like this instead:
sudo dnf install @development-tools

Then take time to read and scroll, to see what it wants to install. So many times if you feel uncomfortable you still can choose N to abort the install.

1 Like

There also is a fedora virtual machine manager that is native to the distro.
QEMU/KVM is available and all that is required to get it working is to install libvirt and virt-manager then use the installed VMM (virtual machine manager) to create and run the VMs.
sudo dnf install libvirt virt-manager

2 Likes

I’ve got it, thanks for the information, I will follow these instruction for a VM instead to have the VirtualBox installed. But how can I solve my problem?

I’ve already executed such commands on Terminal, and now it seems my Kernel is totally broken. As I’ve said, no Wi-Fi connection (and I don’t have an Ethernet port on my laptop), graphical glitches and furthermore is not possible to turn off or restart the OS, only option is Sleep.

Is there anyway to revert back to a previous status of the OS without having the laptop connected on internet? Or is too late and I need to re-install Fedora from scratch?

You can try to press ESC while starting your system and select an older kernel to boot.
If this helps it is good, if not you probably have to reinstall.

Anyway, we do need more information about your system.

brand new laptop

is a too general information.

Thanks a lot ilikelinux, I’ve tried to press Esc while the system was starting up and I’ve been prompted to the kernel selection. These are the ones showing up:

Fedora Linux (6.1.10-200.fc37.x86_64)
Fedora Linux (6.1.9-200.fc37.x86_64)
Fedora Linux (6.0.7-301.fc37.x86_64)

Obviously I didn’t include the rescue option and UEFI firmware settings. Now, if I select the Kernel version 6.1.9, I am able to restore the system as it was before, so everything working smoothly, Wi-Fi recognized, etc. The VirtualBox is not working anymore now, since I have reverted to a previous Kernel version, but I care less because I will try your solution instead. The problem now is that if I restart the system, it will be selected automatically the version 6.1.10 and so I have the same problem as before.

How can I make Fedora selecting by default the version of the Kernel 6.1.9? Is there a way to remove the 6.1.10 version?

Also, since you have asked it and I do apologies for not having mentioned it before, my laptop is an Asus Vivobook 16X R5 16GB. It came with Windows 11 pre-installed but I have totally formatted the system to have Fedora only. And since I am studying CyberSecurity, it was requested to use Kali Linux, but I wasn’t able to install it since it seems there is an issue with Kali Linux installer and the Wi-Fi card of my Laptop not being recognized, so the installer was stuck. I’ve been able to run Kali on VirtualBox tho, but as I’ve said, the Kernel was messing Fedora.

And by the way, I am totally happy to stay with Fedora, I’ve heard lots of great things about this OS, so I want to learn more about it.

To get the index number of all the installed kernels:

  sudo grubby --info=ALL | grep -E "^kernel|^index"

The output should be something like this:

 index=0
 kernel="/boot/vmlinuz-5.15.10-200.fc35.x86_64"
 index=1
 kernel="/boot/vmlinuz-5.15.10-lqx1.0.fc35.x86_64"
 index=2
 kernel="/boot/vmlinuz-5.15.8-200.fc35.x86_64"
 index=3
 kernel="/boot/vmlinuz-5.15.8-lqx1.0.fc35.x86_64"


Now we can change the default kernel by using the index number:

 sudo grubby --set-default-index=1


Verify that the right kernel has been set as default:

   sudo grubby --default-title

The output will be the default kernel title:

 Fedora Linux (5.15.10-lqx1.0.fc35.x86_64) 35 (Workstation Edition)

https://discussion.fedoraproject.org/t/old-kernels-removal/77046/2

2 Likes

That method of setting the index number as default works, but has one flaw.

When the next kernel is installed it will become index 0 and each of the others already installed get bumped down on number in the index, so what was index 1 is now index 2 and what was index 0 is now index 1. The end result is that the kernel you chose as index 1 is no longer index 1, so the method of selecting the kernel by index number is only a temporary solution.

I found that if you edit /etc/default/grub which should already have the statement

GRUB_DEFAULT=saved

and you add the statement

GRUB_SAVEDEFAULT="true"

then run the command sudo grub2-mkconfig -o /boot/grub2/grub.cfg

The effect will be to select whichever kernel you choose from the grub menu when you boot and set it as default for future boots, independent of its location in the indexing.

3 Likes

Thank you everyone, I’ve managed to fix the Kernel and now Fedora is running perfectly. I’ve decided first to run the correct kernel by pressing Esc from the boot phase. Then I’ve followed the instruction to remove the Kernel that I didn’t wanted, so it was index 0. By removing the index 0, the Kernel indexed 1 automatically became 0 so I didn’t need to set the preferred Kernel following the instructions provided by @computersavvy . So for my situation, the instructions provided by @ilikelinux are all what I needed, but it depends obviously by the case.

Now I will follow the instructions to set up a VM by using only the pre-installed tool Boxes in Fedora. Cheers!