How to Fix KVM Error for VirtualBox on Ubuntu 24.04

Screen capture of vbox error fix
vbox Error Fix

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:

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:

lsmod | grep kvm

Finding the kvm module names

This will tell you the names of the kvm modules. In my case, it looked like this:

tedl@tedl-Gazelle:~$ lsmod | grep kvm
kvm_intel             487424  2
kvm                  1409024  1 kvm_intel
irqbypass              12288  1 kvm

kvm module names

You can disable the kvm kernel extensions from running in root mode by typing:

sudo rmmod [kvm_name]

rmmod command syntax

Replace [kvm_name] with the name obtained with lsmod. In my case, it was:

sudo rmmod kvm_intel
sudo rmmod kvm

rmmod for my machine

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!