For testing Hyper-V, it sometimes helpful if you can run a Hyper-VM inside another Hyper-VM. In this post, you will learn how to set up nested Hyper-V virtualization.
Avatar
Latest posts by Anthony Howell (see all)

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
  • 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:

The Intel Processor Identification Utility

The Intel Processor Identification Utility

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
Creating a new VM in PowerShell

Creating a new VM in PowerShell

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'
The installation screen for Server 2019

The installation screen for Server 2019

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
Installing Hyper V using PowerShell

Installing Hyper V using PowerShell

And once that installs, reboot your system to complete the configuration

Restart-Computer
Waiting for the server to finish installing Hyper V

Waiting for the server to finish installing Hyper V

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:

The nested hypervisor

The nested hypervisor

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.

avataravatar
1 Comment
  1. Avatar
    Raimund Andree 5 years ago

    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.

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account