Fix: VirtualBox can't operate in VMX root mode (VERR_VMX_IN_VMX_ROOT_MODE)

Quick guide to diagnose and fix the error when VirtualBox cannot access hardware virtualization because KVM is using VT-x/AMD‑V.

Problem

When starting a VM, VirtualBox shows the error:

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).
Result Code:
NS_ERROR_FAILURE (0X80004005)
Component:
ConsoleWrap
Interface:
IConsole {6ac83d89-6ee7-4e33-8ae6-b257b2e81be8}

This means VirtualBox is trying to use hardware virtualization (Intel VT-x / AMD‑V) but the host kernel already has KVM claiming the CPU virtualization features.

Common Causes

  • The KVM kernel modules (kvm_intel or kvm_amd) are loaded.
  • You recently used QEMU/KVM or your distribution auto-loads the KVM modules at boot.
  • Both KVM and VirtualBox require exclusive access to VT-x / AMD‑V, so they cannot run simultaneously in the host.

Quick (temporary) fix — unload KVM modules

Run these commands in a terminal. Use kvm_intel for Intel CPUs or kvm_amd for AMD CPUs. You may need root privileges.

sudo rmmod kvm_intel
sudo rmmod kvm_amd
sudo rmmod kvm

# Verify KVM modules are unloaded
lsmod | grep kvm

If lsmod | grep kvm returns nothing, KVM is unloaded and VirtualBox should be able to start VMs.

Permanent solution — blacklist KVM modules at boot

If you mostly use VirtualBox and rarely use KVM/QEMU, you can prevent the KVM modules from loading automatically:

sudo nano /etc/modprobe.d/blacklist-kvm.conf

Add these lines:

blacklist kvm
blacklist kvm_intel   # for Intel CPUs
blacklist kvm_amd     # for AMD CPUs

Save the file and reboot. The modules will not load automatically after boot.

Notes & alternatives

  • KVM and VirtualBox both need direct access to the CPU's virtualization features, so they cannot both be the host-level hypervisor at the same time.
  • If you need to run both technologies simultaneously, you could run VirtualBox inside a KVM virtual machine using nested virtualization, but this is more complex and may be unstable or slower.

Want a small helper script to toggle KVM on/off without rebooting? I can prepare one for you — tell me if you want an Intel or AMD version.

0 Comments:

Post a Comment