How to get VirtualBox working on Fedora 41 with KVM installed
If you have KVM (livbvirt
) installed on your system, and are running a kernel >= 6.12
, you may have noticed that VirtualBox VM's are not starting anymore.
This happens because since that kernel version KVM initializes virtualization on module loading by default. You'll get an error similar to this:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "41f2287c-b506-4a8e-abaa-60e7ab641bc9", "--type", "headless"]
Stderr: VBoxManage: error: VirtualBox can't enable the AMD-V extension. Please disable the KVM kernel extension, recompile your kernel and reboot (VERR_SVM_IN_USE)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole
The quick fix is to unload the kvm
modules.
- First double check if you have the KVM modules loaded:
sudo lsmod | grep -i kvm
If you do, you'll get something like this:
kvm_amd 249856 0
kvm 1449984 1 kvm_amd
I'm using an AMD CPU, but if you're using Intel your output similar.
- Now unload the modules:
sudo modprobe -r kvm_amd && sudo -r modprobe kvm
And try to launch you VirtualBox VM's again. They should work now.
When you're done with them you have to load the modules again (if you want to keep using KVM) or restart your computer. To load the modules:
sudo modprobe kvm_amd && sudo modprobe kvm
This is a temporary fix. If you want a permanent one you can add the parameter kvm.enable_virt_at_load=0
to your kernel command line. This is out of scope of this quick tutorial as the unload / load modules method is good enough for me.