My need was to create a Hyper-V VM with Windows 10 where I can install Visual Studio and all my development tools without touch my production machine.
One limitation on that configuration was running “Windows Mobile/Phone” emulator because Hyper-V can’t be nested on an Hyper-V VM.
Fortunately, starting from build 10565 (I’m running on build 10586.71, version 1511) is now possible, so I gave it a try.
First start with “limitation” that we have once nested virtualization is enabled in a virtual machine:
- Dynamic memory must be OFF. This will prevent the VM from booting.
- Runtime memory resize will fail.
- Applying checkpoints to a running VM will fail.
- Live migration will fail.
- Save/restore will fail
And now the “requirement”:
- A processor with Intel VT-x.
- At least 4 GB RAM available for the virtualized Hyper-V host.
- Only Hyper-V can nested, other Hypervisors will not work.
How to set it up:
There is a Microsoft powershell script that do the work for you:
Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/Virtualization-Documentation/master/hyperv-tools/Nested/Enable-NestedVm.ps1 -OutFile ~/Enable-NestedVm.ps1
~/Enable-NestedVm.ps1 -VmName "VmName"
Otherwise you can do it manually:
Enable Virtualization Extension for the vCPU (required)
Set-VMProcessor -VMName "VMName" -ExposeVirtualizationExtensions $true
Disable Dynamic Memory (required)
Set-VMMemory -VMName "VMName" -DynamicMemoryEnabled $false
Enable MAC spoofing (optional)
Once nested virtualization is enabled in a VM, MAC spoofing must be enabled for networking to work in its guests.
Set-VMNetworkAdapter -VMName "VName" -MacAddressSpoofing on
Set VM Memory to 4Gb (optional)
Without 4GB or more, you may not be able to start VMs.
Set-VMMemory -VMName "VMName" -StartupBytes 4294967296
Enjoy running VM inside a VM :-)