- Set up nested Hyper-V virtualization - Mon, May 20 2019
- Set up a Hyper-V home lab with the AutomatedLab PowerShell module - Thu, May 9 2019
Before you get too excited about trying to run Hyper-V inside of Hyper-V, you should check to make sure that you've got hardware that supports it.
Requirements
- Operating system: Windows Server 2016 or newer or Windows 10 Anniversary Update or newer
- VM configuration version 8.0 or higher
- This is standard in Windows Server 2016+, but if you migrate a virtual machine (VM) from an older Hyper‑V server, you may run into this issue.
- An Intel processor with VT-x and EPT
- VT is Intel's Virtualization Technology, VT-x, the base version of VT. Here's Intel's instructions on how to figure out if your processor is supported.
- EPT is Intel's Extended Page Table technology; it allows a guest OS to modify its own page tables in memory. You can use the previously linked tool to determine whether your processor supports EPT.
- Hyper-V is installed on the host system you want to nest on
In my lab, I have a Dell R610 that shipped new in 2010, and it supports nested virtualization, so this isn't limited to brand-new hardware.
One thing to note is that Intel's Processor Identification Utility isn't accurate for my processor:
But if I check the official processor page on Intel's site, it clearly states they support both VT-x and EPT on this processor. If you need to double-check your processor, just type the model into Google, and it will list Intel's page for it.
First steps
Once you have determined if your hardware supports nested Hyper-V, the first step is to create a VM to use as your nested hypervisor:
New-VM -Name 'NestedHyper-V' -MemoryStartupBytes 16GB -NewVHDPath D:\HypV\NHV.vhdx ‑NewVHDSizeBytes 50GB
Then you'll need to enable nested virtualization by configuring the virtual processor on that VM. A successful run will have no output.
Note: It is very important that this happens while the VM is still powered off.
Set-VMProcessor -VMName 'NestedHyper-V' -ExposeVirtualizationExtensions $true
To enable networking on your nested Hyper-V machine, you want to be sure either to configure NAT or MAC address spoofing. It is much easier to enable MAC address spoofing, so that is what I have done in my lab. This will allow your nested VMs to access your physical network and the internet if you want to let them.
Get-VM 'NestedHyper-V' | Set-VMNetworkAdapter -MacAddressSpoofing On
With that done, you can go ahead and install Windows:
Set-VMDvdDrive -VMName 'NestedHyper-V' -Path D:\LabSources\ISOs\WindowsServer19.iso Start-VM -Name 'NestedHyper-V'
Configure the VM
Once you've installed Windows on your VM, be it Windows Server 2019 like what I've installed or another Windows OS, you are now ready to install Hyper-V!
Install-WindowsFeature Hyper-V
And once that installs, reboot your system to complete the configuration
Restart-Computer
Now that you've installed Hyper-V on your VM, you are ready to build a nested VM so that you can take screenshots like this:
It can be pretty trippy working inside a VM that's inside a VM, so don't get lost!
Caveats
There are a couple of things to keep in mind when working with nested virtualization in Hyper-V.
There's no support for dynamic memory. This means that any VM you run inside of your nested Hyper‑V VM will not be able to allocate its memory dynamically. However, this does not affect VMs running on the physical host.
Subscribe to 4sysops newsletter!
There's no support for third-party virtualization apps. In other words, there's no support for any virtualization applications other than Hyper-V while running inside a Hyper-V VM.
Read the latest IT news and community updates!
Join our IT community and read articles without ads!
Do you want to write for 4sysops? We are looking for new authors.
If you are bored running through this great article a 2nd time, use the script Lab in a Box 1 – HyperV.ps1 part of AutomatedLab to deploy you lab in a box in about 1 hour. There is also an Azure version of the script available.