I'm trying to follow this tutorial to run KVM nested in WSL 2, but after following the directions through compiling the kernel and loading it, the test kvm-ok
reports that KVM is not supported.
I've tried multiple options: enabling hyper-v, disabling it, verifying BIOS/CPU support, enabling/disabling Device Guard, other steps in some vmware docs (bcdedit /set hypervisorlaunchtype, suboptions under gpedit/DeviceGuard).
When I do disable hyper-v, set hypervisorlaunchtype off, and disable Device Guard, then I get the following options in system info, but then wsl2 fails to launch at all, saying "Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS."
Any other configuration I try, sys info says that a hypervisor is running and won't show the hyper-v values, but I end up running into the initial problem of KVM not being supported in WSL2. Also if I try enabling "Virtualize Intel VT-x/EPT" in VMWare Player, that fails to launch as well.
Stepping back, ultimately what I'm trying to do is run the firecracker demo on my windows laptop. So if there's an easier way to do this then lmk.
Update
I noticed it works in VMWare Player with an Ubuntu image. Or at least, kvm-ok reports that it's enabled, /dev/kvm exists. I'd still rather use WSL2. But it's refusing to load.
Top line of the screenshot, and first line of the linked article. It requires an insider dev build of Windows. Mine was running the GA version. Enrolling in the insider program and downloading latest worked.
All the settings in the screenshots are correct, and it should be
bcdedit /set hypervisorlaunchtype auto
.I got 400 KVM VM's launched from WSL on my laptop in under 60s! (First 200 in under 15s).
Also note I got KVM working in VMWare Player, but the firecracker test never quite worked. It launched the VM's but they didn't do anything. Apparently VMWare is type-2 and would be slower even if it does work, so I gave up on that approach.
You can try the following guide to enable WSL2 nested virtualization in win10 pro/enterprise (note the disclaimer, you should maybe backup your distros with wsl --export):
https://gist.github.com/xtrnc/496da9243bab29629bc0461562bff458
It worked on my win10 (build 19043.1348). You probably won't need to compile the kernel if you've updated Windows (which is how the Linux kernel is updated now).
If you can upgrade your OS, you can also try that. It should be enabled by default in win11 (along with WSLg).
Note: if you follow the guide it will be necessary to run the script at every restart; also it's necessary to add your user to the kvm group for permissions (on ubuntu
usermod -a -G kvm <USER>
)I have taken the same steps as you and got
in
dmesg
Hyper-V is enabled and in BIOS Virtualization Technology and VT-d Features are enabled.After I enabled Windows Hypervisor Platform I finally had
In a lot of guides I read WSL requires Virtual Machine Platform. But that alone wasn't sufficient for me. For some reason it only worked when I ticked Hyper-V, Virtual Machine Platform and Windows Hypervisor Platform.