How to Fix KVM Error for VirtualBox on Ubuntu 24.04
Recently, after installing an Ubuntu 24.04 Desktop build in VirtualBox running on an Ubuntu 22.04 Desktop host, I encountered an error when trying to run the 24.04 Desktop virtual machine (vm) after the build:
VirtualBox can't operate in VMX root mode. Please disable the KVM kernel extension, recompile your kernel and reboot (VERR_VMX_IN_VMX_ROOT_MODE).
A quick search for the error message led me to this post on VirtualBox's forum: https://forums.virtualbox.org/viewtopic.php?f=1&t=15720
I didn't dig too deeply into why this happens or how the fix clears it, but the down and dirty version is, at the command line on your Linux host, type:
This will tell you the names of the kvm modules. In my case, it looked like this:
You can disable the kvm kernel extensions from running in root mode by typing:
Replace [kvm_name] with the name obtained with lsmod. In my case, it was:
I did not have to rebuild my kernel. I restarted VirtualBox and the vm started fine.
If you've run into this error, I hope you find this post helpful and you're able to quickly get your VirtualBox vm's back online!