Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualBox - Cannot access kernel driver #321

Closed
sjmackenzie opened this issue Jul 20, 2015 · 21 comments
Closed

VirtualBox - Cannot access kernel driver #321

sjmackenzie opened this issue Jul 20, 2015 · 21 comments

Comments

@sjmackenzie
Copy link

Following the nixops tutorial in the manual I came across this error.

I am not running a headless setup.

Even installing the most recent rev of nixops the error persists. (4b53c3d)


$ nixops deploy -d 894a3787-2ef9-11e5-8f06-56847afe9799
webserver> creating VirtualBox VM...
webserver> Virtual machine 'nixops-894a3787-2ef9-11e5-8f06-56847afe9799-webserver' is created and registe
webserver> UUID: de026fd2-0f98-4745-b255-57ab19702002
webserver> Settings file: '/home/stewart/VirtualBox VMs/nixops-894a3787-2ef9-11e5-8f06-56847afe9799-webse
webserver> creating disk ‘disk1’...
webserver> 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
webserver> Clone hard disk created in format 'VDI'. UUID: 827d793b-e185-4200-a875-290670fb1491
webserver> attaching disk ‘disk1’...
webserver> Waiting for VM "nixops-894a3787-2ef9-11e5-8f06-56847afe9799-webserver" to power on...
webserver> VM "nixops-894a3787-2ef94b53c3d03b5af73122307383ae1c22146ae302c4-11e5-8f06-56847afe9799-webserver" has been successfully started.
error: command ‘['VBoxManage', 'startvm', u'nixops-894a3787-2ef9-11e5-8f06-56847afe9799-webserver']’ fail

I get a popup saying:

Cannot access the kernel driver!
The VirtualBox Linux kernel driver (vboxdrv) is eithr not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

'etc/init.d/vboxdrv setup'

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps trace of Linux kernel changes and recompiles the vboxdrv module if necessary.

[button "Abort"]
@statusfailed
Copy link

I get a similar error, but with the text "Kernel module is unavailable". However, it only occurs of the "VirtualBox" GUI is not open. If I have the GUI running, it works fine. As a workaround, does opening the GUI help you?

@domenkozar
Copy link
Member

did you try modprobe vboxdrv? Are you using another virtualization as QEMU?

@jerith666
Copy link

[root@mmchenry-nixos:/etc/nixos]# modprobe vboxdrv
modprobe: FATAL: Module vboxdrv not found.
[root@mmchenry-nixos:/etc/nixos]# nixos-version 
15.09.706.45128de (Dingo)

@jerith666
Copy link

I had both linuxPackages.virtualbox and virtualisation.virtualbox.host.enable = true. When I commented out linuxPackages.virtualbox, it started working. I believe there were some warnings about virtualbox collisions with both enabled. I'm now at:

# nixos-version 
16.03pre71289.7ae05ed (Emu)

@eskimor
Copy link

eskimor commented Dec 31, 2015

Same for me. /dev/vboxdrv is present and has group vboxusers, permissions are ok, I am in group vboxusers - all fine. But when I run nixops deploy -d mystuff I get a "Kernel driver not accessible" pop up. Funnily it works when I run it as root and even more interesting: Running VirtualBox by my self works without problems.

@domenkozar
Copy link
Member

Are you running libvirtd or something else with qemu?

@jerith666
Copy link

It's been a long time since I looked at this, but I'm pretty sure I wasn't running libvirtd or qemu when it failed for me.

@danbst
Copy link
Contributor

danbst commented Sep 1, 2016

I can name one more possible reason for this error. If you didn't reboot an instance for a long time, and regularly update channel, you can end up with booted kernel != nixpkgs kernel.

If you install virtualbox then, with NixOS option, you won't get vbox drivers, because kernel versions do not match. Doing a reboot is sufficient, I think, didn't try rebooting.

@themoritz
Copy link

I can confirm @danbst. Rebooting my host machine solved that (and I indeed did some channel updates after which I haven't rebooted).

@p-alik
Copy link

p-alik commented Feb 2, 2018

I got the issue by running VBoxManage startvm also

$ nix-env -q | grep -i virtual
virtualbox-5.1.26
VirtualBox-GuestAdditions-5.1.26-4.13.11
virtualbox-modules-5.1.26-4.13.11
# uname -r
4.9.60
# nixos-version 
17.09.1971.937ea32f1f (Hummingbird)
# modprobe --dry-run vboxdrv
modprobe: FATAL: Module vboxdrv not found in directory /run/current-system/kernel-modules/lib/modules/4.9.60

vidbina added a commit to vidbina/nixos-configuration that referenced this issue Mar 15, 2018
Using the `virtualbox` package in conjunction with the
`virtualization.virtualbox.host.enable = true` flag causes the Kernel
access denied problem. Solved by following instructions on
NixOS/nixops#321
@bburdette
Copy link

bburdette commented May 13, 2018

No luck for me - virtualbox seems broken either from VirtualBox app or from nixops, sudo or not. vboxdrv error as seen here. Hopefully ec2 will work better!

Edit: just had to add this to configuration.nix: virtualisation.virtualbox.host.enable = true;

@asymmetric
Copy link
Contributor

Can this be closed?

@AmineChikhaoui
Copy link
Member

I think so, please re-open if there are more issues.

@asymmetric
Copy link
Contributor

asymmetric commented Apr 16, 2019

Funny that I should ask to reopen this, but here goes:

I've been having this problem with the wireguard module (on a new Hetzner Cloud box, using either 18.09 or 19.03). Am I correct in assuming that until nixos-infect isn't updated to a newer channel, it is not possible to install kernel modules without rebooting?

In other words, the scenario outlined by @danbst is practically guaranteed to happen for most people, right?

Or did I misunderstand, and nixos-infect is only used for DO, making this irrelevant for all other backends?


EDIT: Turns out I was wrong. The issue will always present itself, but only on DO and the unreleased Hetzner Cloud backend (which also uses nixos-infect).

@jappeace
Copy link

I think modules are searched for in /run/booted-system. The most recent version is in /run/current-system.

So if you want to do this for a running system without a reboot (such as in my case), you have to either trick nixos into believing the module exists in the booted-system, or convince modprobe to use current-system.

Doing this on a running system shouldn't be a problem for minor releases. However, playing around with kernel modules that could be abi incompatible may cause your system to crash.

@asymmetric
Copy link
Contributor

or convince modprobe to use current-system.

@jappeace How would you go about doing that?

@jappeace
Copy link

@asymmetric well I bit the bullet in rebooted, but if you really want to hack, you can replace the symlink, or try to bypass modprobe (insmod seems like fun). I'd prefer bypassing though, who knows what that symlink does. File system seems to be write-able so that totally invites these hacks.

Both commands still seem to attach version numbers so you'd need to create a symlink in the directory above that too with right hacked version number.

God speed.

@sjmackenzie
Copy link
Author

Placing the answer here for my future self:
NixOS/nixpkgs#52429
#370

@dpaetzel
Copy link

I just recently stumbled across the same error when I added pkgs.virtualbox to systemPackages as well as setting virtualisation.virtualbox.host.enable to true. Only after I removed pkgs.virtualbox from systemPackages I was able to start VMs. This behaviour really surprised me; might be a bug? Might actually be a regression since it worked until my last upgrade?

Note: In #370, the presented solution is to not have VirtualBox in your user environment (which I never did).

@jmercouris
Copy link

I confirm what @dpaetzel has said. One must ONLY have virtualisation.virtualbox.host.enable = true in their configuration.

@Mayravixx
Copy link

Having the exact same problem on my Manjaro system. When I do modprobe vboxdrv I just get the error modprobe: FATAL: Module vboxdrv not found in directory /lib/modules/5.10.61-1-MANJARO. I've spent a good hour and a half trying to fix it, and nothing I do seems to work at all. Tried rebooting my system multiple times, using reflector to update my arch mirrors, installing virtualbox from their website for "all linux distros" vs using my package manager, installing the dkms packages for virtualbox, installing linux-headers, the list goes on and on. Like goddamn, all I wanna do is run TEdit for my creative world in Terraria lmao.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests