Enable Nested Virtualization in Hyper-V on Windows 11
Nested virtualization allows you to run Hyper-V inside a Hyper-V virtual machine, enabling scenarios like running WSL2, Docker, or nested virtual machines within a guest operating system. This guide provides a concise, step-by-step walkthrough on configuring your Windows 11 host to support nested virtualization using PowerShell, covering prerequisites, configuration commands, and essential network adjustments.
Prerequisites
Before enabling nested virtualization, ensure the following requirements are met: * The host machine is running Windows 11 Pro, Enterprise, or Education. * The host has an Intel processor with VT-x or an AMD processor with AMD-V support. * The target virtual machine is powered off. * The target virtual machine uses Configuration Version 8.0 or higher.
Step 1: Turn Off the Virtual Machine
Nested virtualization settings cannot be modified while the virtual machine is running.
- Open Hyper-V Manager.
- Right-click your target virtual machine and select Turn Off (or Shut Down).
Step 2: Enable Virtualization Extensions via PowerShell
Windows 11 requires PowerShell to expose hardware virtualization extensions to the guest VM.
- Right-click the Start menu and select Terminal (Admin) or PowerShell (Admin).
- Run the following command, replacing
<VMName>with the exact name of your virtual machine:
Set-VMProcessor -VMName "<VMName>" -ExposeVirtualizationExtensions $true- To verify that the setting was applied successfully, run:
Get-VMProcessor -VMName "<VMName>" | Select-Object ExposeVirtualizationExtensionsThe output should display True.
Step 3: Enable MAC Address Spoofing (Recommended)
If you plan to run virtual machines inside the guest VM that need network access, you must enable MAC Address Spoofing on the guest VM’s network adapter.
Run the following command in your elevated PowerShell window:
Get-VMNetworkAdapter -VMName "<VMName>" | Set-VMNetworkAdapter -MacAddressSpoofing OnStep 4: Start the VM and Install Hyper-V
- Start the virtual machine.
- Inside the guest operating system, open PowerShell as Administrator and run the following command to enable the Hyper-V role:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All- Restart the guest virtual machine when prompted.
How to Disable Nested Virtualization
If you ever need to disable nested virtualization on the virtual machine:
- Shut down the virtual machine.
- Run the following command in PowerShell as Administrator on the host:
Set-VMProcessor -VMName "<VMName>" -ExposeVirtualizationExtensions $false