Language: EN

hyper-v-nested-virtualization

How to enable nested virtualization in Windows

Today we are going to solve how to use nested virtualization within a Hyper-V environment in Windows 10, 11, or higher.

Nested virtualization is a technique that allows you to run virtual machines (VM) within another VM. In other words, a VM inception. A virtual matryoshka doll of VMs.

hyper-v-nested-virtualization-1

And why do we want to do this? To impress ourselves and show off? Well, yes, also, … but not just for that.

It’s actually easier than you think to get to this situation: for example, if you are using a virtual machine for development, or a virtual machine for testing with virtual machines.

hyper-v-nested-virtualization-2

But more so, you may need it just by using Windows Subsystem for Linux (WSL) or Windows Subsystem for Android (WSA) in a virtual machine.

Because WSL and WSA are great tools that use virtualization internally to function. So if you use a virtual machine for development… oh oh! You’re going to have a little problem.

Fortunately, it is very easy to enable nested virtualization. First, we open a command prompt and get a list of our virtual machines with this command,

Get-VM

hyper-v-nested-virtualization-3

Make sure that the machine in which you want to enable nested virtualization is stopped. If not, stop it with this command.

Stop-VM -Name 'your-vm-name'

Where obviously you will have to change ‘your-vm-name’ to the name of the machine you want to work with.

The VM configuration should be version 8.0 or higher. In any case, and just in case, update the virtual machine with this command,

Update-VMVersion -Name 'your-vm-name'

Finally, now yes, we enable nested virtualization in the virtual machine with this command.

Set-VMProcessor -VMName 'your-vm-name' -ExposeVirtualizationExtensions $True

We restart our VM. We will be able to access it and proceed to install the Hyper-V role or feature and any other dependent on it. With nested virtualization enabled, we will be able to run virtual machines within the host VM and test different virtualization environments.

This option is very useful for testing different virtualization environments and conducting integration tests with different operating systems. And as we have seen, it’s just a matter of a couple of commands to enable it.