How to Fix VirtualBox Errors after Linux Version Upgrades

I just upgraded from Fedora 35 to Fedora 36 and, like many upgrades in the past, found that VirtualBox would not launch a VM. The specific error that results from this failure can vary from one release to another but this time it was the following.


This error, like most of the others I have encountered after a Fedora version upgrade, indicates that there is a problem with the VirtualBox kernel module. The specifics really don’t matter all that much but the general recommendations I have found on the Internet usually amount to “rebuild the kernel modules.” Unfortunately, most of the specifics attached to that statement don’t usually work for all cases.

Having recovered from this many times I have finally determined a repeatable procedure that works reliably. Therefore I have decided to publish my procedure. The commands in this document are specifically for Fedora, but the equivalent commands for your package manager should work for you.

# rpm -qa | grep -i virtualbox

Remove all of the packages listed by that command. Your list will differ from mine but you will need to list each package separately when removing them or they will not all be removed. And that seems to be the source of the problem. You can see from the listing of my results that there are still some old versions of some of these packages. I suspect that this is because I have installed VirtualBox in multiple ways. For example I have installed one instance from the Fedora RPMFusion repository. I have also installed multiple Fedora versions that I downloaded directly from the VirtualBox web site and the more generic AMD version. I did this to circumvent these kernel module problems in the past but the different dependencies never got completely cleaned up.

Be aware that removing VirtualBox-kmodsrc-6.1.34-2.fc36.noarch or its equivalent for your distribution also removed a number of dependencies that are actually needed by VirtualBox. This is to be expected and all the required dependencies will be reinstalled when VirtualBox is reinstalled.

I simply installed the Virtualbox version that is available from the RPMFusion repository. This installed all necessary dependencies and worked perfectly when tested.

# dnf install VirtualBox

If your distro’s repository does not have a package for VirtualBox you can download one from the VirtualBox website and install it locally.