How to Configure Nested Virtualization in WSL 2 on Windows 11 Using PowerShell

Developers working with bare-metal container runtimes, Kubernetes Minikube clusters with KVM drivers, Android Studio emulators, or QEMU virtual machines inside Linux require hardware-assisted virtualization extensions (Intel VT-x or AMD-V). In standard setups, virtual machines cannot spawn sub-virtual machines. By enabling nested virtualization in Windows Subsystem for Linux (WSL 2), Windows 11 passes host hardware virtualization extensions directly through the hypervisor into the Linux kernel.

Prerequisites for Nested Virtualization

Ensure your Windows 11 host satisfies the following architectural criteria:

  • Windows 11 version 21H2 or newer.
  • A modern processor featuring hardware virtualization support (Intel Haswell / Core 4th Gen or newer, or AMD Ryzen processors).
  • Hardware virtualization enabled in your computer’s UEFI/BIOS configuration.
  • WSL 2 active as the default architecture.

Configuring Nested Virtualization in .wslconfig via PowerShell

To pass CPU virtualization flags into Linux globally using PowerShell:

# Define global WSL configuration path
$wslConfigPath = "$HOME\.wslconfig"

# Construct nested virtualization configuration payload
$configContent = @"
[wsl2]
nestedVirtualization=true
networkingMode=mirrored
localhostForwarding=true
"@

# Write configuration file with UTF8 encoding
Set-Content -Path $wslConfigPath -Value $configContent -Encoding UTF8
Write-Host "Nested virtualization configured in $wslConfigPath" -ForegroundColor Green

This automated script writes nestedVirtualization=true into your user profile’s global configuration file.

Restarting WSL to Expose Virtualization Extensions

To initialize the virtual machine with hardware virtualization enabled:

  1. Open an elevated PowerShell prompt and execute:
    wsl --shutdown
  2. Relaunch your Linux distribution:
    wsl
  3. Inspect CPU flags inside Linux to confirm hardware virtualization pass-through:
    egrep -c '(vmx|svm)' /proc/cpuinfo
  4. A returned count greater than 0 confirms that Intel vmx or AMD svm hardware extensions are actively exposed inside Linux.
  5. Verify that the KVM device node exists:
    ls -l /dev/kvm

Accelerating Container and Emulator Performance

With /dev/kvm active, add your standard user account to the kvm group (sudo usermod -aG kvm $USER) to run high-performance virtualised testing suites without privilege friction.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.