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)
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.exeIf successful go ahead.
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.exeSince 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 VBoxManagePatch 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.
@marcvroom @vzezzos
Probably vagrant is trying to use ubuntu’s virtualbox. Maybe this will fix it.
Also your VagrantFile might need this
@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.