I never thought I would have much use for enabling nested virtualization, but I came across this how to post, by Senthil Kumar, at the top of my Mastodon feed this morning and thought that I would give it a shot and try to address an issue on a Windows 10 VM where WSL2 would not start because nested virtualization was not enabled. TL;DR, the steps below resolved the issue.
Process to Enable
By the way, I am using KVM on with libvirt and qemu on a Gentoo machine with an Intel processor for all of the steps outlined below. Process should be similar, but perhaps not exactly as below for AMD processor and linux distributions other than Gentoo.
Turn off VMS
Seems like I only have two VMs running at the moment.
Unload KVM Module
As mentioned earlier, I am running on an Intel based CPU.
Reload KVM Module With Nested Setting Going Forward
Not much to say here, just reloading same module with nested=1 parameter, and that I should have scheduled down time for the VMs as the Nagios alerts start arriving.
Set KVM module to Load with nested permanently.
I am doing this on a Gentoo machine with SystemD, so to make the module load this way on reboot I put the .conf file in /etc/modules-load.d/, where the systemd-modules-load.service will pick it up.
Verify Nesting Is Supported
Enable Nesting in Guest VM
I am not interested in nesting in ether of the two VMs I shut down, and I want to stop the alerts, so I am going to power them on first.
OK, with the VMs running again, and the Nagios ‘Recovered” messages arrived, It’s time to configure the guest in which I want nesting enabled. When I went through the steps below, I discovered that I had no changes to make to the definition of my VM, as it already had the necessary in place, so I essentially justed looked at the configuration and closed it. I started the Win10 VM and launched WSL2 with Ubuntu successfully, something which was not working before enabling nesting.
Success in a Screen Shot
WSL2 working in a VM thanks to a post from OSTechNix
Chrls is currently a technology transformation leader at one of the oldest American investment banking services holding companies, headquartered in New York City. Previous roles at current employer include project manager, front office support, retail and enterprise global Windows server support. Currently residing in Tennessee on the Cumberland Plateau and enjoying life, family and open source.