Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get Oracle vm VirtualBox 6.0 and wsl working at the same time

when i Turn on Windows Subsystem for Linux option in Windows features on or off

VirtualBox out an error every time i run a vm

Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED). Result Code: E_FAIL (0x80004005) Component: ConsoleWrap Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

is there a way to fix the VirtualBox error without turn off wsl

like image 661
bob Avatar asked Sep 20 '19 16:09

bob


People also ask

Can you run WSL and VirtualBox at the same time?

Will I be able to run WSL 2 and other 3rd party virtualization tools such as VMware, or VirtualBox? Some 3rd party applications cannot work when Hyper-V is in use, which means they will not be able to run when WSL 2 is enabled, such as VMware and VirtualBox.

Can I use both VirtualBox and VMware?

Yes, that's correct.

Can virtual machines communicate with each other?

Private network—allows a virtual machine to communicate only with another virtual machine on the host. Internal network—sets up communication between the host system and the virtual machines on it. External network—connects virtual machines and the host physical network.


2 Answers

I found it! After much research, and trial and error, here is what enabled me to run VMs in VirtualBox on Windows 10 with Windows Subsystem for Linux installed:

In an elevated (admin) cmd.exe or PowerShell, do:

bcdedit /set hypervisorlaunchtype off

and make sure Hyper-V and Windows Sandbox are disabled in Windows Features (which you can get to by entering OptionalFeatures.exe at a command prompt, or via the Control Panel).

Also, Virtualisation options should be enabled in the BIOS, and I think (I don't have time to test right now) that "Virtual Machine Platform" and "Windows Hypervisor Platform" should be enabled.

VirtualBox 6.0.14, Windows Version 10.0.18362.356.

like image 164
drkvogel Avatar answered Oct 12 '22 13:10

drkvogel


VirtualBox + WSL2 (on Windows 10 & 11) 🎉

It's possible to have VirtualBox and WSL2 running at the same time on Windows 10 as well as on Windows 11! Please note that when running both in parallel, VirtualBox is then only capable of running in its slower software virtualization mode.

To setup both systems, make sure that the virtualization options are enabled in your BIOS!

  • Virtual Box - install the newest version on your machine (official download)
  • WSL2 - simply run the command wsl --install in an elevated PowerShell or CMD (official docs)

Troubleshooting

Necessary Windows Features?

Installing WSL via the command line should automatically turn on the following Windows features:

  • Virtual Machine Platform
  • Windows Subsystem for Linux

WSL uses the Hyper-V architecture underneath but the actual Hyper-V features doesn't need to be enabled. In other words: WSL uses the Hyper-V architecture but not the Hyper-V feature (thanks @Cito).

Enable/Disable Windows Features

You can find and edit the Windows features via:

  • Open Control Panel > Programs > Turn Windows Features on or off, or
  • Enter OptionalFeatures.exe into a CMD or PowerShell terminal

Using Windows Home?

If you are running Windows Home, some features might not be installed on your machine. To manually add those virtualization features follow this tutorial.

WSL stopped working?

If you already had WSL installed and made changes to Windows features, WSL might have stopped working all together. Especially when WSL was installed via one of the old methods (not via the wsl --install command line). To repair the WSL installation, you can do the following:

  1. Uninstall and remove WSL completely from your system (backup your files if needed!)
  2. Deactivate all virtualization features
  3. Restart machine
  4. Do a fresh and clean install of WSL via the command line wsl --install
  5. Restart machine again

Slow VirtualBox VMs?

If you see this green turtle symbol turtle icon in the guest window's status bar, VirtualBox is running in software virtualization mode (which is really slow!). The hardware virtualization mode would be displayed with this blue symbol hw virtualization mode icon.

When running in software mode, the reason is most probably an active WSL setup, which relies on the Hyper-V architecture. Another reason could be the Hyper-V features to be turned on. To get back to hardware virtualization mode, make sure that the following features are turned off:

  • Hyper-V
  • Windows Hypervisor Platform

and that the hypervisorlaunchtype is set to off in the Windows Boot Configuration Data (BCD) store. To do so, run the following commands from an elevated command line:

bcdedit /set hypervisorlaunchtype off

After changing the BCD, a reboot is required.


More Information

For more information on:

  • VirtualBox virtualization modes in relation to the Windows features, see the official thread
  • Mircosoft WSL and VirtualBox in combination, see the official Github thread
like image 13
winklerrr Avatar answered Oct 12 '22 13:10

winklerrr