34

When I turn on Windows Subsystem for Linux option in Windows features on or off, VirtualBox outputs the following 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 turning off WSL?

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
bob
  • 537
  • 1
  • 5
  • 12
  • I have this problem as well - I've tried all other fixes that I can find, and compared my system with a colleague's whose setup is the same apart from that he does not have WSL installed - he can run VMs in VirtualBox, I can't. It seems to be WSL that is preventing VMs from starting. Does anyone know if this is a known problem? – drkvogel Oct 20 '19 at 22:49

3 Answers3

40

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.

drkvogel
  • 2,061
  • 24
  • 17
  • 4
    Worked for me only after enabling Virtual Machine Platform and Windows Hypervisor Platform. Thank you! – Tanase Butcaru Jan 24 '20 at 16:47
  • 7
    With Virtualbox 6.1.4 you can instead enable Virtual Machine Platform and Windows Hypervisor Platform. This version can successfully use Hyper-V as backend instead of conflicting with it. – Paul Stelian Mar 23 '20 at 09:50
  • 1
    Wish I can give you more votes! Works a charm. I had to enable Virtual Machine Platform and Windows Hypervisor Platform. – Hein du Plessis Oct 13 '20 at 18:38
  • @HeinduPlessis It took me ages to find this solution to this problem, which was causing me a lot of stress when starting a new job that required me to run VMs on Windows - I should have linked to the place I found it, perhaps, it was not easy to find - but hopefully other people who had this problem will find this! :) – drkvogel Oct 14 '20 at 09:38
  • @PaulStelian Is that with WSL installed? It seemed to be WSL that was causing the conflict, but maybe it has been fixed in later versions of VirtualBox as you say. And now there is WSL2... – drkvogel Oct 14 '20 at 09:41
  • 1
    @drkvogel WSL1 doesn't have any conflicts with Virtualbox at all (if Virtualbox doesn't work it's unrelated to WSL1, but may be related to the feature Core Isolation in Windows Defender, or to Credential Guard/Device Guard)... WSL2 is the one requiring Hyper-V (and using Virtual Machine Platform). If you want to use Virtualbox without disabling Hyper-V (and WSL2) you enable Windows Hypervisor Platform and use Virtualbox 6.1.4 or newer. – Paul Stelian Oct 15 '20 at 11:46
  • 2
    I have installed VirtualBox 6.1.18, but VirtualBox still not working with WSL2. (Windows 10 Home) Also, after doing this, my WSL2 won't start. Can anyone confirm it still works? – Shinebayar G Jan 25 '21 at 18:56
  • must reboot after `bcdedit /set hypervisorlaunchtype off` – Sayyed Dawood Nov 04 '21 at 06:39
  • 1
    It's not working for me either using WSL2 and VirtualBox `6.1.28`. @PaulStelian I tried your approach as well but it is not working. – winklerrr Nov 09 '21 at 09:40
  • @winklerrr Device Guard and Secure Core all enable Hyper-V; 6.1.28 is actually a version that _does_ use Hyper-V if it finds it, and complains about how slow it is, rather than just failing to start. So any failure comes from Virtualbox itself not having implemented the feature correctly (which is why I don't use it nowadays) – Paul Stelian Nov 09 '21 at 18:42
  • WSL2 DOES use the hypervisor, requiring `bcdedit /set hypervisorlaunchtype auto`. This answer does not work on Windows 10 22H2 build 19045.2965 – mrtumnus Jun 01 '23 at 14:53
23

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:

winklerrr
  • 13,026
  • 8
  • 71
  • 88
  • Windows 10 does not work with 6.1.28. but I upgraded to 6.1.32 and it works :) – Alireza Feb 06 '22 at 11:45
  • 1
    @Alireza thank you for your comment! I've updated my post :) – winklerrr Feb 07 '22 at 07:43
  • Not sure, it looks like if wsl is activated, virtualbox will use software based virtualization. – Riccardo Manzan Feb 14 '22 at 18:33
  • @Tx_monster how can I check/validate this? – winklerrr Feb 17 '22 at 11:22
  • 1
    @winklerrr read first comment here: https://forums.virtualbox.org/viewtopic.php?t=99390 Keep in mind that wsl uses hyper-v under the hood. – Riccardo Manzan Feb 17 '22 at 13:22
  • 1
    You only need the "Virtual Machine Platform" and "Windows Subsystem for Linux". The "Hyper-V" feature is not required. Instead of enabling/disabling the Windows features, you can now also install WSL 2 with the simple command "wsl --install". – Cito Feb 17 '22 at 18:20
  • 1
    @Tx_monster thank you! I added the symbols to my post, as I find them quite useful to know! – winklerrr Feb 18 '22 at 09:36
  • @Cito thank you! I've updated my post accordingly. Everything should now be correct. Can you verify? – winklerrr Feb 18 '22 at 09:37
  • 1
    @winklerrr Thanks for the corrections. Maybe explicitly mention that Hyper-V and Hypervisor platform features are not needed for WSL because many believe that or are unsure, because WSL in fact uses Hyper-V architecture, but not the Hyper-V feature. In the last section on VBox, it still says that WSL relies on the Hyper-V feature. – Cito Feb 18 '22 at 13:35
  • 2
    Not working for me. After completely uninstalling WSL, turning of all virtualization features, and then running `wsl --install` only the features _Virtual Machine Platform_ and _Windows Subsystem for Linux_ were back on again. With `hypervisorlaunchtype off`, VirtualBox is fine, but WSL not. And with `hypervisorlaunchtype auto`, WSL is fine, but VirtualBox is painfully slow in software virtualization mode. And switching requires a reboot. Every time :( – René Steetskamp Jun 21 '22 at 07:50
  • @RenéSteetskamp Same situation for me. – Mike Lowery Jul 14 '22 at 20:40
  • WSL2 DOES use the hypervisor, requiring `bcdedit /set hypervisorlaunchtype auto`. This answer does not work on Windows 10 22H2 build 19045.2965. – mrtumnus Jun 01 '23 at 14:52
0

in november 2019, i upgraded my Windows 10 family to release 1909 (run winver to check). I wanted to use WSL2.

And then i was unable to run the VMs in Oracle Virtualbox :

Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED).

I had to check the "Plateforme Hyper-V" in "Turn Windows features ON or OFF" And it went OK.

Francis
  • 91
  • 1
  • 1