MicrosoftDocs / WSL

Source code behind the Windows Subsystem for Linux documentation.
https://docs.microsoft.com/windows/wsl
Other
1.9k stars 562 forks source link

Please add the fact that WSL2 is not co-exists with VirtualBox 6.0.x #536

Closed rengui closed 4 years ago

rengui commented 4 years ago

wsl2-faq Will I be able to run WSL 2 and other 3rd party virtualization tools such as VMware, or VirtualBox? states:

......and versions of VirtualBox before VirtualBox 6 (VirtualBox 6.0.0 released in December 2018 now supports Hyper-V as a fallback execution core on a Windows host!)

This is quite misleading...

according to here and here, WSL2 is still not co-exists with VirtualBox 6.0.x yet.

when WSL2 is running, starting VirtualBox 6.0.x virtual machine will failed:

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}

I'm quite expecting WSL2 and VirtualBox 6.0 can running at the same time, but before that comes true, could you please correct the faq doc? Thanks!

craigloewen-msft commented 4 years ago

From the Virtual Box 6.0.0 changelog, it states that it can also use Hyper-V as the fallback hypervisor.

image

As well, Oracle's documentation says that it's possible to run Hyper-V with Virtual Box.

I think you're running into a specific error, to me Oracle is clearly indicating that they do have support for Hyper-V which is why we have the link our docs that say so. Is there a way we could make the statement clearer?

rengui commented 4 years ago

yes, Hyper-V and VirtualBox 6.0 looks can play together, as the Oracle document you mentioned as well as the here (those time there is no WSL2 yet).

but now it really looks problem to have WSL2 together with VirtualBox,




maybe it's not a bug of WSL doc nor WSL2, but Windows (Hyper-V API) or VirtualBox......

Just record some more details for the errors I met. (maybe there have no way but waiting newer version of Windows10 and/or VirtualBox)

HostOS: Win10 Insider 18990 x64 (for WSL2) VirtualBox: latest 6.0.14 (as of now 6.1.0 comes out, maybe need to try on it.)

Errors when starting VMs when Hypver-V enabled (with WSL2 running) -- All VMs are able to running correctly when disabled Hyper-V.

Biswa96 commented 4 years ago

Source: https://forums.virtualbox.org/viewtopic.php?f=6&t=90853&sid=f20b0f7f51e462005f9b3be80a567617&start=120#p453078

Try this command:

VBoxManage setextradata global "VBoxInternal/NEM/UseRing0Runloop" 0

It works but very slow with type 2 hypervisor because type 1 is already in the chair.

rengui commented 4 years ago

Source: https://forums.virtualbox.org/viewtopic.php?f=6&t=90853&sid=f20b0f7f51e462005f9b3be80a567617&start=120#p453078

Try this command:

VBoxManage setextradata global "VBoxInternal/NEM/UseRing0Runloop" 0

It works but very slow with type 2 hypervisor because type 1 is already in the chair.

Thanks a lot. It really works :)

follow the same link, below is a bit safer to try(affect not globally, but only the VM you are editing)

# add one line to your VM.box file <ExtraData> section
<ExtraDataItem name="VBoxInternal/NEM/UseRing0Runloop" value="0"/>
rengui commented 4 years ago

Thanks @Biswa96

Since the WA

goto C:\Program Files\Oracle\VirtualBox
# for one VM
VBoxManage setextradata "<VM Name>" "VBoxInternal/NEM/UseRing0Runloop" 0
or 
# globally
VBoxManage setextradata global "VBoxInternal/NEM/UseRing0Runloop" 0

is working with

I'm closing this ticket.

wooseopkim commented 4 years ago

I've struggled for days because of this! Thanks for all the work. You saved my day.

peterhadac commented 4 years ago

Same problem here, thanks very much for helping ! Is there any efect on performance of VM ?

earonesty commented 4 years ago

Yes, running with this disabled hurts the performance of vbox. WSL consumes some sort of "hypervisor type 1 slot", so vbox won't run. You should be able to run both at once, but you can't. Shutting down WSL2, and starting VBOX can be done on the same machine.... but not both at once.

gitthail commented 4 years ago

I don't think I understand the purpose WSL2. You can't break all virtualization, that renders it useless to me.

I think the solution (when I can face the effort) is uninstall windows, put fedora on the bare metal and then kvm/qemu windows on top with hardware passthrough, and any other VMs needed can run in parallel.

oki-burokku commented 4 years ago

WSL2 is not yet fit for purpose. Wasted best part of a day trying to figure out this one. Winding back to WSL1.

jlearman commented 4 years ago

I too am unable to get WSL2 to work with VirtualBox. I'm running Ubuntu on both WSL and VB. When WSL2 is enabled and I start my Ubuntu in VB, I get a blank rectangular screen with a rapidly blinking cursor, which persists indefinitely. Of course, I configured HyperV for the VB VM, and made sure that HyperV was enabled in Windows Features.

What's worse, disabling WSL2 using any of the normal means doesn't restore VB to working state. Fortunately I was able to use Windows Restore to just before I installed WSL2 and it works. I did this twice; the second time I had to restore back to the first installation of WSL2, and this time I also had to reinstall ("Repair") VB.

It would be great to use WSL2, but for now I have to stick to WSL1 because I need VirtualBox; I need its ability to checkpoint.

oki-burokku commented 4 years ago

WSL2 works fine with vmware player (which is the setup I am using now). Microsoft broke something in virtualbox with WSL2, I have verified this on a couple different workstations. Did not appear to be virtualbox's fault, but it is unusable ATM. I guess it will be fixed sometime....

ivictbor commented 3 years ago

Thanks @Biswa96

Since the WA

goto C:\Program Files\Oracle\VirtualBox
# for one VM
VBoxManage setextradata "<VM Name>" "VBoxInternal/NEM/UseRing0Runloop" 0
or 
# globally
VBoxManage setextradata global "VBoxInternal/NEM/UseRing0Runloop" 0

is working with

  • Win10 Insider 18990 x64 (for WSL2)
  • VirtualBox-6.1.0

I'm closing this ticket.

Works but. Machine was loaded, worked several minutes and got frozen. Probably just because of slow hypervisor type 2 performance

onomatopellan commented 3 years ago

@ivictbor Try latest version 6.1.16, it has some fixes for Hyper-V. https://www.virtualbox.org/wiki/Downloads

JulioJu commented 3 years ago

@onomatopellan but it could work, or not . See https://github.com/MicrosoftDocs/WSL/issues/798

Spongman commented 3 years ago

this should be reopened. the workarounds only work for some users and even when they do the performance is terrible and the guests are still unstable and prone to crashes. yes, with VB 6.1.16

pabloruizsoria commented 3 years ago

It is not working here. I have wasted 2 days before reading this topic. Windows 10 pro WSL installed 2 days ago Virtual Box and extension pack reinstalled twice in the last version

I cannot install new machines I cannot run machines previously installed

mareksloser commented 3 years ago

It is not working here. I have wasted 2 days before reading this topic. Windows 10 pro WSL installed 2 days ago Virtual Box and extension pack reinstalled twice in the last version

I cannot install new machines I cannot run machines previously installed

I have same situation. I cant use docker and VirtualBox at same time. When i switch off windows function hyper-V, i can use Virtualbox, but cant use a docker.. (it can solve your problem)

Salmondx commented 3 years ago

@craigloewen-msft could you please provide your vision if this will ever be solved for WSL2? Currently we can't use WSL2 at all because it blocks us from using vagrant and virtualbox, and since WSL1 is no longer supported - news are bad for web developers.

That's a really common question when people are switching from WSL1 to WSL2 (e.g. lots of themes on reddit, stackoverflow and etc, this one for example: https://stackoverflow.com/questions/62184881/virtualbox-and-wsl2).

Vagrant/Virtualbox pair are still popular especially among web developers (e.g. its de facto a standard dev env for Laravel and other web frameworks).

craigloewen-msft commented 3 years ago

@Salmondx Virtual Box 6.0.0 and VMware 15.5 both support running simultaneously with Hyper-V. The Hyper-V team has been working with these other tools to ensure that they can run well with Hyper-V enabled. I understand that in cases like VirtualBox performance can be degraded right now, but to answer the base question of this thread, yes they are currently able to exist together, and I personally would hope that the performance here would improve so both can be run simultaneously with no perceived degradation.

Salmondx commented 3 years ago

Thanks for response! The problem is that it's not even possible to mount folders to virtualbox Hyper-V VM from WSL2 filesystem. May be in some artificial example they can coexist, but it's far from being useful. Given that files should be stored inside WSL2 filesystem now, it's safe to say that they don't work together.

craigloewen-msft commented 3 years ago

I see, is the feature request here that you can use both tools simultaneously for separate projects? Or that you'd like to use both tools simultaneously on the same projects (i.e: Store your project in the WSL 2 file system and then access that same project folder from a VirtualBox VM?)

Salmondx commented 3 years ago

@craigloewen-msft on the same project. Imagine a typical nodejs/laravel/whatever web app: it should live in WSL2 filesystem so you could use all the required tools like npm, compilers and etc. And virtualbox/vagrant should be able to mount folders from WSL2 filesystem into VM.

That's how I use WSL1 today (and probably almost everyone in this thread 😄).

Cito commented 3 years ago

@Salmondx It's even a problem when you want to use them in different projects, because every time you need VirtualBox you need to first un-install the WSL feature which is extremely inconvenient, since it also needs a reboot.

@craigloewen-msft No, they are not able to exist together. It's not only that if you have WSL-2 installed, then the performance is slower. It's also that (depending on your CPU and the guest BS) some virtual boxes simply crash which work otherwise well when WSL-2 is not installed. It's not only me, many other users are reporting this in #798.

Spongman commented 3 years ago

in cases like VirtualBox performance can be degraded right now,

@craigloewen-msft i think you're understating the issue here. the performance, when it works at all, is terrible.

maybe there is some hidden communication going on between MS & Oracle, but all i see is bidirectional finger-pointing and/or whitewashing.

ivictbor commented 3 years ago

@Salmondx It's even a problem when you want to use them in different projects, because every time you need VirtualBox you need to first un-install the WSL feature which is extremely inconvenient, since it also needs a reboot.

@craigloewen-msft No, they are not able to exist together. It's not only that if you have WSL-2 installed, then the performance is slower. It's also that (depending on your CPU and the guest BS) some virtual boxes simply crash which work otherwise well when WSL-2 is not installed. It's not only me, many other users are reporting this in #798.

I am doing exactly like this,

  1. When I need VM, I run
DISM /Online /Disable-Feature:VirtualMachinePlatform 
PowerShell Disable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -All 
bcdedit /set hypervisorlaunchtype off
  1. Reboot

  2. Work in VM

DISM /Online /Enable-Feature:VirtualMachinePlatform 
PowerShell Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -All 
bcdedit /set hypervisorlaunchtype auto start
  1. Reboot back

I was asked about it too many times, so I even created a hint to paste URL😀 https://hinty.io/devforth/wsl-2-starter-guide-must-read/

Yes WSL 2 is cool, but seams like for now it is easier to buy another PC if you need a VirtualMachines for development

Cito commented 3 years ago

@Spongman The problems seem to be hard to reproduce and depend on things like the host CPU, the guest OS and the various settings in VB. I have the impression that the performance degradation and frequency of crashes seem to be worse for some than for others. That's probably one of the reasons why some believe it already works and this is not really moving forward.

zsbaksa commented 3 years ago

@Salmondx It's even a problem when you want to use them in different projects, because every time you need VirtualBox you need to first un-install the WSL feature which is extremely inconvenient, since it also needs a reboot. @craigloewen-msft No, they are not able to exist together. It's not only that if you have WSL-2 installed, then the performance is slower. It's also that (depending on your CPU and the guest BS) some virtual boxes simply crash which work otherwise well when WSL-2 is not installed. It's not only me, many other users are reporting this in #798.

I am doing exactly like this,

  1. When I need VM, I run
DISM /Online /Disable-Feature:VirtualMachinePlatform 
PowerShell Disable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -All 
bcdedit /set hypervisorlaunchtype off
  1. Reboot
  2. Work in VM
DISM /Online /Enable-Feature:VirtualMachinePlatform 
PowerShell Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -All 
bcdedit /set hypervisorlaunchtype auto start
  1. Reboot back

I was asked about it too many times, so I even created a hint to paste URL😀 https://hinty.io/devforth/wsl-2-starter-guide-must-read/

Yes WSL 2 is cool, but seams like for now it is easier to buy another PC if you need a VirtualMachines for development

Mate, you just saved my whole day. My VM now is working again, without any issues :)

Thank you

Pysis868 commented 3 years ago

Rebooting is not an option. Clearly WSL2/Windows VM functionality is causing the conflicts here and even with VirtualBox 6.1.18 and becoming exhausted with settings and lengthy guides this situation still needs to improve.

Like others said, I will downgrade WSL to 1 or disable entirely and find another way to run Docker, using windows subsystem support, Desktop app for it, or even neither.... Definitely preferring to keep VirtualBox and continue using my Cygwin environment being far more open than this WSL2 'exclusive' nonsense....

Also false hope..: "WSL2 breaks VirtualBox 6.1" https://github.com/MicrosoftDocs/WSL/issues/798#issuecomment-823543229

gitthail commented 3 years ago

I've taken a swing at this on 3 separate occasions over the past 2 years.

Don't waste your time.

If you need VBox for work, don't even look at WSL

peschue commented 3 years ago

VirtualBox 6.1.22 does not work with the VBoxManage setextradata global "VBoxInternal/NEM/UseRing0Runloop" 0 described above.

Attaching the log of my attempt. VBox.log

Error is

00:00:02.790862 VMSetError: F:\tinderbox\win-6.1\src\VBox\VMM\VMMR3\NEMR3Native-win.cpp(1418) int __cdecl nemR3NativeInitAfterCPUM(struct VM *); rc=VERR_NEM_VM_CREATE_FAILED
00:00:02.790891 VMSetError: Failed to get device handle and/or partition ID for 0000000001353ac0 (hPartitionDevice=0000000000000c45, Last=0xc0000002/1)
00:00:02.790907 NEM: Destroying partition 0000000001353ac0 with its 0 VCpus...
00:00:02.792421 ERROR [COM]: aRC=E_FAIL (0x80004005) aIID={872da645-4a9b-1727-bee2-5585105b9eed} aComponent={ConsoleWrap} aText={Failed to get device handle and/or partition ID for 0000000001353ac0 (hPartitionDevice=0000000000000c45, Last=0xc0000002/1) (VERR_NEM_VM_CREATE_FAILED)}, preserve=false aResultDetail=-6805
00:00:02.792580 Console: Machine state changed to 'PoweredOff'
00:00:02.813113 Power up failed (vrc=VERR_NEM_VM_CREATE_FAILED, rc=E_FAIL (0X80004005))
00:00:03.313816 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600
00:00:03.313907 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={4680b2de-8690-11e9-b83d-5719e53cf1de} aComponent={DisplayWrap} aText={The console is not powered up}, preserve=false aResultDetail=0
00:00:03.314591 GUI: Aborting startup due to power up progress issue detected...

Tried many combinations, and I have all my development in WSL2, so will probably need to drop VirtualBox and use a separate machine for embedded programming where I need USB/JTAG access from Linux.

Edit: I agree that this should be reopened. Not sure what WSL2 can do about it, though.

Faq commented 3 years ago

@peschue is it working with vb 6.1.24? also better to oen new issue (if there is not one) as this one is closed.

peschue commented 3 years ago

@Faq it does not work with the latest version (6.1.26)

Agrover112 commented 3 years ago

Actually I agree VirtualBox doesn't work

ivictbor commented 3 years ago

Actually we all must admit that it never worked. I mean that temporary fix made vbox awfully slow anyway so I doubt that any guest os with minimal X server was usable by anyone, if I am wrong could someone please share expirience? And disabling hyperv and rebooting any time when you need to work on other distro/image is definitely not a way to go

gitthail commented 3 years ago

It never worked for people who require performance from the guest. I've gone back to windows and tried to get it going several times over the years.

Pehrsonal commented 2 years ago

had been lovely to have virtualbox and sub-system running at the same time!

OpenCoderX commented 2 years ago

Just dropping by to express sadness.

Agrover112 commented 2 years ago

@OpenCoderX use VMWare?

CTBlaze commented 2 years ago

It still doesn't work, WIn11 Home, WSL2, latest updates and VirtualBox 6.1.32 (and lower versions) Whatever happened to virtualization being a total abstraction and indirection for the guest/client? Why does Hyper-V have to reserve the ACTUAL hardware exclusively? this is just wrong, Microsoft, and once again I say: you should be sued by the world's people for havin introduced and caused so much inproductivity and loss of energy and time, that you should be shut down for good ;)

CTBlaze commented 2 years ago

having said that, anybody tried running VirtualBox inside Ubuntu which runs in WSL2 ?

gmankab commented 2 years ago

still don't work

norru commented 2 years ago

As of VB 6.1.32, it's still impossible to run WSL2 and VirtualBox at the same time.

EDIT: to clarify, a full desktop distro (even lightweight) is too slow to be usable.

Cito commented 2 years ago

As of VB 6.1.32, it's still impossible to run WSL2 and VirtualBox at the same time.

According to my own experience and what I read from the comments above, it works, with the caveat that VirtualBox is slower ("turtle mode"). How much slower depends on the CPU and configuration of the VM, e.g. some claim that VMs with only one CPU assigned work better. Some also report crashes, but this seems to happen only with certain host CPUs and VM configurations, and should be reported on the VirtualBox bug tracker.

norru commented 2 years ago

Works

As of VB 6.1.32, it's still impossible to run WSL2 and VirtualBox at the same time.

According to my own experience and what I read from the comments above, it works, with the caveat that VirtualBox is slower ("turtle mode"). How much slower depends on the CPU and configuration of the VM, e.g. some claim that VMs with only one CPU assigned work better.

I've tried that, it's unusable for me as I'm running a desktop in the VM. Hence "doesn't work".

Some also report crashes, but this seems to happen only with certain host CPUs and VM configurations, and should be reported on the VirtualBox bug tracker.

Yes, I think it's a matter for the VB dev team now. ~EDIT: I am not able to access the VirtualBox wiki and bug tracker at this time.~ It's an open issue in VB https://www.virtualbox.org/ticket/20357

lx30011 commented 2 years ago

what a mess

mims92 commented 2 years ago

I have virtualbox 6.1.34 and wsl2 and it is working. I had to change the acceleration (system >acceleration) from default to Hyper-v. Note that it works with 1 cpu only

norru commented 2 years ago

I have virtualbox 6.1.34 and wsl2 and it is working. I had to change the acceleration (system >acceleration) from default to Hyper-v.

Doesn't work for me if I use more than 1 CPU in the VM. The VM just doesn't boot (or takes so long to boot that it's indistinguishable from a crash)

mims92 commented 2 years ago

True, i have updated my comment

dbjungle commented 2 years ago

I have virtualbox 6.1.34 and wsl2 and it is working. I had to change the acceleration (system >acceleration) from default to Hyper-v.

Doesn't work for me if I use more than 1 CPU in the VM. The VM just doesn't boot (or takes so long to boot that it's indistinguishable from a crash)

I have the exact same experience. I have seen a lot of reports suggesting they can work together, but this is the only time I've seen it mentioned that it only works with one CPU assigned. I am now able to boot my VBox VM, but I wouldn't call this working.