WSL: Cannot install Virtualbox

Description

I am able to sudo apt-get install virtualbox vagrant but when I attempt a vagrant up I am presented with an error. This ends at a Linux headers error, and since WSL is only the userspace and not the kernel am I correct in thinking that there is no current fix for this?

Expected results

Vagrant box comes up fine

Actual results

VirtualBox is complaining that the installation is incomplete. Please
run `VBoxManage --version` to see the error message which should contain
instructions on how to fix this error.

So then I run VBoxManage --version

WARNING: The character device /dev/vboxdrv does not exist.
         Please install the virtualbox-dkms package and the appropriate
         headers, most likely linux-headers-3.4.0+.

         You will not be able to start VMs until this problem is fixed.
4.3.36_Ubuntur105129

And then I run sudo apt-get install linux-headers-3.4.0+

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-3.4.0
E: Couldn't find any package by regex 'linux-headers-3.4.0'

Windows build number

Version 10.0.14393 Build 14393

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

With the new build you can run Windows executables so I propose the following to run Vagrant on WSL.

First, remove any previous VirtualBox from your WSL. Next Check if you can run windows excecutables by adding the path export PATH=$PATH:/mnt/c/Windows/System32, then try opening notepad.exe

If successful go ahead.

  1. Install Vagrant and check if you can run the windows native VirtualBox cli tool. sudo apt-get install Vagrant export PATH=$PATH:"/mnt/c/Program Files/Oracle/VirtualBox" VBoxManage.exe

  2. Since vagrant requires the executable to be called VBoxManage, I’ve linked it at /usr/bin sudo ln -s "/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe" /usr/bin/VBoxManage VBoxManage

  3. Patch the vagrant drivers to include virtual box 5.0 and 5.1 as per the following instructions https://github.com/mitchellh/vagrant/issues/5572#issuecomment-93250550 Instructions taken from this comment by @PhilipeLouchtch.

At /usr/share/vagrant/plugins/providers/virtualbox/driver/ Copy version_4_3.rb > version_5_0.rb Edit the class to be called version_5_0 and the log a few lines under Repeat for version_5_1

Modify /usr/share/vagrant/plugins/providers/virtualbox/driver/meta.rb find the hashmap on line 48, add after “4.3” => Version_4_3 ,“5.0” => Version_5_0, “5.1” => Version_5_0

Modify /usr/share/vagrant/plugins/providers/virtualbox/plugin.rb find the module Driver and add the following lines autoload :Version_5_0, File.expand_path(“…/driver/version_5_0”, FILE) autoload :Version_5_1, File.expand_path(“…/driver/version_5_0”, FILE)

  1. Enjoy.

@marcvroom @vzezzos

Probably vagrant is trying to use ubuntu’s virtualbox. Maybe this will fix it.

export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
sudo apt-get purge virtualbox
sudo apt-get remove virtualbox-dkms

Also your VagrantFile might need this

v.customize ["modifyvm", :id, "--uartmode1", "disconnected"]

@ricardowong Thanks for your guide, it definitely works well. I would suggest people to not install vagrant from the package manager but rather from vagrant using wget and dpkg -i The package manager has a pretty outdated version of vagrant.

I’m having an issue running vagrant up with this setup. Vagrant invokes the VBoxManage import command. The problem is that the path is for inside of WSL, not windows. VBoxManage tries to prepend D:\ (at least for me) which means the command fails because that path does not exist. Does this mean that we can only use vagrant inside of WSL only after provisioning boxes?

@HeathNaylor – I haven’t tried this, but one option (though a little clunky) would be to call the Windows version of Vagrant from Linux using cbwin.

Hi @MatheusRV, my vagrant is 1.9.5 and my WSL version is 16.04(this is the ubuntu version, right?) and my VirtualBox is 5.1.22. I think all is updated.