I know that most of you want to learn virtualization, and since you have Hyper-V in your company this is a very important task. A common problem is that you can’t test on production systems and a lab is out of the question for a company of your size. If this sounds all too familiar but you’re still eager to learn, nested virtualization will help you out tremendously. Now I’m not going to give you a nice and long definition of what nested virtualization is because Andy already has an article about it where he explains it very well; but long story short, nested virtualization lets us create Hyper-V virtual machines inside a Hyper-V virtual machine or Hyper-V host. Think about it, we can have a Hyper-V farm inside a single box. Off course, this will be only for testing purposes, because production environment won’t support this configuration largely due to the performance impact of running such a setup.

In order to be able to create a nested Hyper-V machine with Windows Server 2016, Hyper-V requires hardware virtualization support (such as Intel VT-x) to run virtual machines. In previous Windows Server versions, such as 2012 and 2012 R2, this capability was hidden from the guest VMs which prevents them from running the Hyper-V server role among other hypervisors. In Windows Server 2016 however, Microsoft has given us the choice to enable this processor capability inside a VM using PowerShell.

Before moving forward I presume you have already installed Windows Server 2016 on your host (the bare metal server), as well as the Hyper-V role. Also, make sure in the BIOS of the hardware you have the virtualization support available and enabled.

Create Nested Hyper-V

Now you’ve got that ready, let’s move into creating our first Hyper-V virtual machine.

Creating a Hyper-V nested virtual machine

Open the Hyper-V console and from the Actions pane click New > Virtual Machine;  or right-click the host and follow the same steps.

Create Nested Hyper-V manager

On the first page of the New Virtual Machine Wizard, name the new VM and provide a location for the virtual disk(s) and configuration files.

New virtual Machine Wizard

In the Specify Generation page choose the second option to create a generation 2 virtual machine. This one has better performance and supports the newest features.

Virtual Machine Wizard Generation

Since this will be a Hyper-V host, as far as the virtual machines that will run on it know, we will have to allocate a fair chunk of memory. Based on how much RAM you have on your physical server and how many VMs you want to run on this Hyper-V virtual machine, assign the right amount. Ensure that Use Dynamic Memory for this virtual machine is not selected then click Next.

Virtual Machine Wizard Assign memory

Select the virtual switch you want this virtual machine to be connected to then continue the wizard.

Create Nested Hyper-V networking

Provide the path for the virtual disk then the size of it. If you intend to keep and run the virtual machines on this disk, make it big, if not use the appropriate size just for the OS.

Create Nested Hyper-V virtual hard disk

Choose how you want to install the OS then click Next. This settings can be also configured alter on.

Create Nested Hyper-V installation

Click Finish to create our first virtual machine soon to be a Hyper-V virtual machine.

Create Nested Hyper-V wizard

Once created, power on the VM and install Windows Server 2016. I’m not going to put the installation steps here which consist simply of just booting from the network and doing a few clicks on the installation wizard.

hyper-v manager

Once you get it up and running and try to install Hyper-V on the virtual machine an error will be presented:

Hyper-V cannot be installed: the processor does not have required virtualization capabilities.

virtual machine connection

The message pops-up because, by default, the hypervisor hides the hardware virtualization support capability from guest VMs. The next steps are to use some PowerShell command lines to enable virtualization support capability for guest VMs. Shut down the virtual machine then execute the commands shown below. The first one lets you see if virtualization support is enabled for the VM, and the second one enables virtualization support. The problem about running the second command line is that no message is displayed if it succeeds.

windows powershell administrator

In case you want to speed things up and try to enable virtualization support while the virtual machine is still running, you will get an ugly error message in PowerShell; so make sure the VM is off.

Set-VMProcessor : Failed to modify device ‘Processor’. Cannot change the processor functionality of a virtual machine now.
“…” Cannot change the processor functionality of virtual machine ‘Server-HV01’ while it is running.

windows powershell administrator

Now power on the virtual machine and try installing Hyper-V. The wizard should let us install the role this time with no problems whatsoever.

Create Nested Hyper-V server roles

I’ve seen people perform a second layer of virtualization, meaning inside this Hyper-V virtual machine they deployed another Hyper-V VM and only then they will start creating the required test machines. You can do that, but I don’t recommend it, because the performance rapidly declines and if you think about it, you don’t even need to. If the test you are doing requires another Hyper-V VM, all you need to do is follow the above steps and create another Hyper-V virtual machine on the bare metal hypervisor.

Create Nested Hyper-V manager

Creating virtual machines inside the nested hypervisor

Once you’re done creating your nested Hyper-V machines, open the console for one of them and start creating virtual machines like you would normally do except now your virtual machines will run inside a virtualized Hyper-V server. Pretty neat, huh??

Create Nested Hyper-V virtual machine connection

As you can see they are running smoothly and if you can afford an SSD drive they will run great.

Create Nested Hyper-V administrator

Now I’ve told you how to create Hyper-V nested virtualization here comes the disclaimer because you’ll quickly find out there are a few features that won’t work. To be honest, I don’t know if it’s such a problem missing these because you are probably not going to make use of them in a test lab anyway. Here they are:

  • Checkpoints are not going to work
  • Live migration is not going to work
  • Live memory resize is not possible. You will have shut down the Hyper-V VM.
  • Does not currently run with AMD processors. <This is the biggest drawback I can find>

Summary

Nested virtualization in Windows Server 2016 brings a new level to virtualization with Hyper-V that is perfect for creating lab environments and learning all there is about Microsoft technologies. I have to say, the feature was implemented very late compared to the competition, and the restriction on AMD processors can be a severe issue for some. However, if the drawbacks don’t affect you it’s a really useful tool, and we should expect some improvements from Microsoft in future updates. Until then, use it as it is and comment below with your own experiences!