WSL2 in a VM requires nested virtualization

I successfully used Séb’s instructions to install WSL in a Windows 10 virtual machine in VirtualBox, but I then failed to upgrade it to WSL2.

WSL2 runs in a virtual machine, so for this to work in a Windows 10 VM, nested virtualization needs to be enabled. I did enable it in my VM’s configuration, but this didn’t seem to make a difference.

I know others have had better luck using kvm and virt-manager. I’ll continue poking at it when I get a chance, in the meantime if anyone has encountered the same problem and has managed to solve it, I’m all ears!

1 Like

@saviq kindly pointed out that VirtualBox’s support for nested virtualization is currently limited to AMD CPUs. No luck with my Intel CPU, I’ll give kvm a try.

Nested virtualization with QEMU/KVM works, and I got WSL2 running in a Windows 10 VM on a 19.04 host.

4 Likes

Why do you need to run the Terminal in WSL2, when you can do that in the (pure) Linux system?

@chanath we’ve already been through this on a different thread. You know the reasons.
Please don’t keep asking the same question over and over.

3 Likes

Is there someone who got WSL2 on the kvm of 18.04 host?

I’m getting the message below when trying install linux distribution on WSL2.

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370109
Error: 0x80370109 ?? ?? ?? ?????? ??? ?? ??? ??? ?? ??? ???????.

Press any key to continue...

@oSoMoN Could you share a working libvirt XML for the KVM/QEMU setup? I got Hyper-V to install inside the VM but wsl2 only returns an error on startup.

I have wsl 1 running on a windows virtual machine with kubuntu 20.04 as host and i am using virtualbox 6.1, which supports intel nested virtualization. i have also enabled nested virtualisation and when i use wsl 1 to check it, i get positive rsults but when converting to wsl 2, it tells me to enbale virtual machine platfrom feature and enable virtualisation when i have already enabled the feature and nested virtualisation and also have enabled hypervisor platform feature… Pls help??

To my knowledge Hyper-V (and thus WSL 2) does not work nested in Virtual Box, which is a type 2 hypervisor. I would recommend using a KVM-based solution instead.

Could you help me set it up since i a just a person who is new to virtualisation and stuff since i have come here out of pure interest

The easiest way to get started with KVM with a GUI is to use gnome-boxes.

Boxes (gnome.org)