What started as a quick VirtualBox install turned into a multi‑headed boss fight: USB errors, a sulking kernel driver, a turf war with KVM, and even a Nix syntax bite. Here’s the complete journey and the fixes that finally made my VM boot.
Head #1 — USB devices wouldn’t enumerate
Can't enumerate USB devices
Could not load the Host USB Proxy service: VERR_NOT_FOUNDRoot cause: Host USB support + Extension Pack missing, and the user not in vboxusers.
Fix (configuration.nix):
virtualisation.virtualbox.host.enable = true;
virtualisation.virtualbox.host.enableExtensionPack = true;
users.users.<your-user>.extraGroups = [ "vboxusers" ];Apply:
sudo nixos-rebuild switch
rebootVerify:
groups | tr ' ' '\n' | grep -x vboxusers
VBoxManage list usbhostHead #2 — “VirtualBox kernel driver is not accessible”
VERR_VM_DRIVER_NOT_ACCESSIBLERoot cause (in my case): launching a per‑user VirtualBox build while the system had different environment/udev context.
Checks:
# modules & devices are fine?
lsmod | grep -E 'vboxdrv|vboxnetflt|vboxnetadp|vboxpci'
ls -l /dev/vboxdrv /dev/vboxnetctl # expect root:vboxusers, mode 660
# you should be in the group
id -nG | tr ' ' '\n' | grep -x vboxusers || echo NOT-IN-GROUP
# make sure you're using the system binaries
which VirtualBox
which VBoxManage
VBoxManage -vFixes that worked:
- Use only the system package (avoid a per‑user copy):
environment.systemPackages = [ pkgs.virtualbox ]; - Restart your session so it picks up
vboxusers(orloginctl terminate-user $USER, then log back in). - Kill stale VBox processes:
pkill -f VBox. - Quick test:
VBoxManage list hostinfoshould work; thenVBoxManage startvm "YourVM" --type headless.
Head #3 — KVM vs. VirtualBox (VMX root mode)
VirtualBox can't operate in VMX root mode
(VERR_VMX_IN_VMX_ROOT_MODE)Root cause: the KVM kernel modules had already claimed hardware virtualization.
Permanent fix (configuration.nix):
boot.blacklistedKernelModules = [
"kvm"
"kvm_intel" # or "kvm_amd" on AMD
];Temporary test without rebuild:
sudo systemctl stop libvirtd 2>/dev/null || true
sudo modprobe -r kvm_intel kvm # or: kvm_amd kvm
lsmod | grep kvm || echo "KVM not loaded"Head #4 — Nix syntax bite – ooops
error: syntax error, unexpected '{', expecting INHERITFix: don’t open a new attrset mid‑file; place options directly in the top‑level { ... } of configuration.nix.
Final validation
# devices
ls -l /dev/vboxdrv /dev/vboxnetctl
# environment
which VBoxManage && VBoxManage -v
# quick health
VBoxManage list hostinfo
# start headless (clear error output)
VBoxManage startvm "ComandoVM" --type headless
# logs (path shown in showvminfo)
tail -n 80 ~/VirtualBox\ VMs/ComandoVM/Logs/VBox.logTL;DR: Fix checklist
- Enable VirtualBox host + Extension Pack; add yourself to
vboxusers. - Use the system VirtualBox binary; kill stale processes; refresh your login session.
- Disable KVM when you need VirtualBox (they can’t share VT‑x).
- Keep
configuration.nixtidy — one misplaced brace can block a rebuild.
After one last reboot with KVM out of the way, the VM finally powered on. The hydra, at long last, was tamed.
Created with AI