Nested Virtualization
  • 15 Jul 2024
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Nested Virtualization

  • Dark
    Light

Article summary

Overview

Nested virtualization allows you to create a lab in CloudLabs VM Labs that contains multiple virtual machines (VMs). You can create and run a virtual machine (guest VM) within a virtual machine (host VM). You can use nested virtualization to provide lab users with multiple related virtual machines as part of the lab.

Nested virtualization is enabled through Hyper-V. It is only available on Windows-based lab VMs. You can run both Windows-based and Linux-based guest VMs inside the lab VM. This document explains the concepts, considerations, and recommendations for nested virtualization in CloudLabs VM Labs.

Use Cases

With nested virtualization, you can support multiple VMs that communicate with each other. You might use such labs for the following purposes:

  • Networking with GNS3

  • IT Administration

  • Ethical Hacking

  • On-Prem Server/Networking Technologies

Enable Nested Virtualization for a Lab

Nested virtualization is configured in CloudLabs VM Labs using Microsoft Hyper-V.

To enable nested virtualization for a lab, you need to enable the Hyper-V feature and tools on the template VM. When you export the VM image and set up a lab using that image, each lab user has a lab VM that already contains the nested virtual machines.

To enable nested virtualization for a lab:

  • Create a lab with the following specifications:

    • Image: Windows Server 2019/2022

    • VM SKU: Medium (nested virtualization) or Large (nested virtualization)

      [Note]: If you are using a customized VM SKU, ensure that you use a compatible VM series, such as StandardDs_V4 or StandardEs_V4

  • Connect to the template VM by using a remote desktop client or CloudLabs Web Connect.

  • Enable Hyper-V feature, configure networking, set up guest VMs, etc. For detailed instructions, see here.

  • Save the template VM and export the VM image to the image gallery.

  • Now, you can update the lab to use newly created images and issue VMs to users.

Best Practices

Here are some best practices to follow when using nested virtualization in CloudLabs VM Labs:

  • Use a supported SKU for the lab VM. Nested virtualization is only supported on Windows 10/11 Enterprise, Windows Server 2016, Windows Server 2019, and Windows Server 2022.

  • Use a supported SKU for the guest VM. You can run both Windows-based and Linux-based guest VMs inside the lab VM, but they must be supported by Hyper-V.

  • Allocate enough resources for the lab VM and the guest VMs. Nested virtualization requires more CPU and memory resources than regular virtualization. Make sure you choose a lab VM size that can accommodate the number and size of the guest VMs you want to run. You can use the documentation to compare the available sizes and their capabilities.

  • Use the latest version of Hyper-V and the latest updates for the lab VM and the guest VMs. Nested virtualization is a relatively new feature that is constantly being improved and updated. To ensure the best compatibility and performance, make sure you use the latest version of Hyper-V and install the latest updates for the lab VM and the guest VMs.

  • You might choose to create a user without admin privileges when you create a lab. Consider the following issues when you use nested virtualization with such an account:

    • To be able to start or stop VMs, the user must belong to the Hyper-V administrators group.

    • The user can't mount drives.

    • The Hyper-V VM files must be saved in a location accessible to the user.

  • To avoid data corruption in the nested virtual machines when the lab VM shuts down, configure the nested VMs to shut down automatically when the lab VM shuts down. See the documentation here.

  • When you create the nested virtual machines, choose the VHDX file format for the virtual hard disks to save disk space on the lab VM.

  • By default, when you create the nested virtual machine, only one virtual CPU (vCPU) is assigned. Depending on the operating system and software of the nested VM, you might have to increase the number of vCPUs.

  • When you create the nested virtual machine, the minimum assigned memory might not be sufficient for the operating system and installed software. You might have to increase the minimum amount of assigned memory for the nested VM.

Resources

For more information about nested virtualization, see the following articles:

FAQs

Q. Can I use VMware instead of Hyper-V for nested virtualization?

A. No, nested virtualization in CloudLabs VM Labs is only supported with Hyper-V. VMware does not support running nested VMs on Azure VMs. For more information, see undefined.

Q. Can I use nested virtualization in Linux-based lab VMs?

A. No, nested virtualization in CloudLabs VM Labs is only supported on Windows-based lab VMs. Linux-based lab VMs do not support Hyper-V, which is required for nested virtualization. However, you can run Linux-based guest VMs inside a Windows-based lab VM.