Hyper-V is more known as a server virtualization technology; however, since Windows 8, it is also available in the client operating system. In Windows 10, Microsoft improved the experience drastically to make Hyper-V an excellent solution for developers and IT Pros.
Microsoft Hyper-V, codenamed Viridian, is a native (type 1) hypervisor that directly runs on the hardware, compared to VMware Workstation, VirtualBox, and other type 2 or hosted hypervisors. It was first released in Windows Server 2008, and it allows you to run virtual machines on x86-64 systems.
As mentioned, with Windows 10, Microsoft optimized Hyper-V for developers. Hyper-V allows developers to quickly spin up development virtual machines on Windows 10 with excellent performance, but it is also used in a couple of other development features as a back-end technology, like the Android Emulator, the Windows Subsystem for Linux 2 or Docker Containers. In this article, we will have a quick look at what Hyper-V on Windows 10 can over for developers.
First, let’s start with one of the essential features to create virtual machines. Now you can not only create Hyper-V virtual machines by installing them with an ISO file; you can use the Hyper-V Quick Create VM Gallery, to quickly create a new Windows 10 Development environment or even an Ubuntu virtual machine. It will download a pre-configured Hyper-V virtual machine with Windows 10 and the visual studio development environment or Ubuntu 18.04 or 19.04. If you want, you can also create your own Quick Create VM images and even share them with other developers.
With the Windows Subsystem for Linux, did Microsoft bring a Linux environment to the Windows 10 desktop, and allows you to run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a full virtual machine. In the latest Windows, 10 Insider Preview builds, Microsoft released a preview of WSL 2. WSL 2 uses Hyper-V virtualization technology to isolate and virtualize WSL in the backend. This provides not just security benefits but also a huge performance boost. You can find more about the Windows Subsystem for Linux 2 on my blog.
One of the difficult parts in the past was the interaction between the virtual machine and the host machine. With the Enhanced Session Mode, Microsoft made it easy to copy-paste files between them and also allows you to map and share devices from the host with the virtual machine. This includes:
Enhanced session mode is enabled by default on Windows 10 Hyper-V, in Windows Server, you will need to enable that feature in the Hyper-V Settings. If you create your own Linux virtual machine, make sure you install the latest virtualization drivers.
A huge benefit of virtualization is the ability to easily save the state of a virtual machine, which allows you to go back or forward at a specific point in time. In Hyper-V, this feature is called a virtual machine checkpoint, formerly known as a virtual machine snapshot.
Hyper-V knows to types of checkpoints:
The checkpoint type can be set by virtual machine. Both types of checkpoints have different advantages and disadvantages. In the latest versions of Hyper-V, production checkpoints are selected by default. However, you can easily change this using the Hyper-V Manager Settings or PowerShell. On my Windows 10 client machine, I prefer to use standard checkpoints, since it also saves the virtual machine memory state, however on production server systems I highly recommend to use production checkpoints, and even then you should be careful.
One of the features which were very painful in the past was networking. With the introduction of the NAT switching option in the Hyper-V virtual switch, you can now easily connect all your virtual machines to the network your host is joined. On Windows 10, you will get a default switch to connect your virtual machines. If this is not enough or you want to leverage the NAT VM Switch on a Hyper-V server, you can use the following commands to create a VM switch and NAT rule.
You can read more about the Hyper-V NAT networking here.
Containers are one of the hot technologies right now, with Docker Desktop for Windows you can run them on your Windows 10 machine. In the background, Windows uses Hyper-V technology to apply additional isolation between the container and the host operating system, so-called Hyper-V Containers. This feature also allows you to run Windows and Linux containers on Windows side by side, without the need of running a full Linux VM on Windows 10.
If you want to interact with your virtual machine running on Windows 10, you can use the Hyper-V Manager and the console to interact with the operating system directly. However, there are also two other options that allow you to manage and access the VMs using the command line. PowerShell Direct lets you create a PowerShell remoting session to the virtual machine using the VM Bus, so no networking is required. The same applies to Linux virtual machines and the HVC tool, which allows you to create an SSH connection directly into the VM. Both options also allow you to copy files to and from virtual machines.
This is extremely handy if you set up some automation, and you need to run some commands within the virtual machine.
Windows Sandbox is a new feature in Windows 10 and was released in version 1903. Windows Sandbox uses Hyper-V technology to provide you with a Windows 10 Sandbox. The Sandbox allows you to spin up an isolated, temporary, desktop environment where you can run untrusted software. The sandbox is great for demos, development, testing, troubleshooting, or if you are dealing with malware. If you close the sandbox, all the software with all its files and state are permanently deleted. It is a Windows 10 virtual machines, with the advantage that it is built into Windows 10, so it leverages the existing OS, which gives you faster startup, less footprint, better efficiency, and easier handling, without losing security.
The Windows Sandbox experience can also be customized with configuration files. So, you can add additional software and tools to your Windows Sandbox. You can read more about Windows Sandbox and how you create the configuration files here.
This one might be not directly development related. However, I think we all have been here. We see a link, and we are not sure if this is a trusted site or if it is a malicious website. With Windows Defender Application Guard, we get an isolated browser, which protects us from malicious websites and software. If a user goes to an untrusted site through either Microsoft Edge or Internet Explorer, Microsoft Edge opens the site in an isolated Hyper-V-enabled container, which is separate from the host operating system.
You can enable Windows Defender Application Guard on Windows 10, using the following steps.
This feature is more about convenience. If you are working and develop inside a virtual machine and you are running this virtual machine console in full-screen mode, you might not notice when your notebook runs out of battery. With the Battery Pass-through feature, the guest operating system inside the virtual machine knows about the battery status. The Hyper-V Virtual Battery feature is enabled by default and works with Windows and Linux virtual machines.
Nested Virtualization lets you run virtualization in a virtual machine, basically like inception for virtual machines. With Hyper-V, you can run Hyper-V within a Hyper-V virtual machine. This is interesting for a couple of different scenarios. First, you can create a virtual Hyper-V host for testing and labs, or you even more important, you can run Hyper-V Containers or Windows Sandbox within a virtual machine. And another great thing about Nested Virtualization, it also works with virtual machines in Microsoft Azure.
To enable nested virtualization within a Hyper-V, you basically can follow this guide.
If you are using Visual Studio to build Android applications, I am sure you already used the Visual Studio Emulator for Android. This enables developers to use a hardware accelerated Android emulator, without needing to switch to Intel’s HAXM hypervisor, which gives them even more performance and speed.
Now, as you can see, Hyper-V is a great developer tool and used for many different features. To Install Hyper-V, you have to check for the following requirements on your machine:
For more information and troubleshooting, see Windows 10 Hyper-V System Requirements.
If you want to enable and install Hyper-V on Windows 10, you can run the following PowerShell command.
For more information on how you can install Hyper-V on Windows 10, you can check the following Microsoft Docs.
I hope this gives you an overview of why Hyper-V is great for developers and enables a lot of different features. If you have any questions, please leave a comment.
Microsoft Hyper-V, codenamed Viridian, is a native (type 1) hypervisor that directly runs on the hardware, compared to VMware Workstation, VirtualBox, and other type 2 or hosted hypervisors. It was first released in Windows Server 2008, and it allows you to run virtual machines on x86-64 systems.
As mentioned, with Windows 10, Microsoft optimized Hyper-V for developers. Hyper-V allows developers to quickly spin up development virtual machines on Windows 10 with excellent performance, but it is also used in a couple of other development features as a back-end technology, like the Android Emulator, the Windows Subsystem for Linux 2 or Docker Containers. In this article, we will have a quick look at what Hyper-V on Windows 10 can over for developers.
Quick Create VM Gallery
First, let’s start with one of the essential features to create virtual machines. Now you can not only create Hyper-V virtual machines by installing them with an ISO file; you can use the Hyper-V Quick Create VM Gallery, to quickly create a new Windows 10 Development environment or even an Ubuntu virtual machine. It will download a pre-configured Hyper-V virtual machine with Windows 10 and the visual studio development environment or Ubuntu 18.04 or 19.04. If you want, you can also create your own Quick Create VM images and even share them with other developers.
Windows Subsystem for Linux 2 (WSL 2)
With the Windows Subsystem for Linux, did Microsoft bring a Linux environment to the Windows 10 desktop, and allows you to run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a full virtual machine. In the latest Windows, 10 Insider Preview builds, Microsoft released a preview of WSL 2. WSL 2 uses Hyper-V virtualization technology to isolate and virtualize WSL in the backend. This provides not just security benefits but also a huge performance boost. You can find more about the Windows Subsystem for Linux 2 on my blog.
Enhanced Session Mode to share devices with your virtual machine
One of the difficult parts in the past was the interaction between the virtual machine and the host machine. With the Enhanced Session Mode, Microsoft made it easy to copy-paste files between them and also allows you to map and share devices from the host with the virtual machine. This includes:
- Makes virtual machines resizable and high DPI aware
- Improves virtual machine integration
- Allows device sharing
Enhanced session mode is enabled by default on Windows 10 Hyper-V, in Windows Server, you will need to enable that feature in the Hyper-V Settings. If you create your own Linux virtual machine, make sure you install the latest virtualization drivers.
Checkpoints
A huge benefit of virtualization is the ability to easily save the state of a virtual machine, which allows you to go back or forward at a specific point in time. In Hyper-V, this feature is called a virtual machine checkpoint, formerly known as a virtual machine snapshot.
Hyper-V knows to types of checkpoints:
- Standard Checkpoints: takes a snapshot of the virtual machine and virtual machine memory state at the time the checkpoint is initiated.
- Production Checkpoints: uses Volume Shadow Copy Service or File System Freeze on a Linux virtual machine to create a data-consistent backup of the virtual machine. No snapshot of the virtual machine memory state is taken.
The checkpoint type can be set by virtual machine. Both types of checkpoints have different advantages and disadvantages. In the latest versions of Hyper-V, production checkpoints are selected by default. However, you can easily change this using the Hyper-V Manager Settings or PowerShell. On my Windows 10 client machine, I prefer to use standard checkpoints, since it also saves the virtual machine memory state, however on production server systems I highly recommend to use production checkpoints, and even then you should be careful.
NAT Networking
One of the features which were very painful in the past was networking. With the introduction of the NAT switching option in the Hyper-V virtual switch, you can now easily connect all your virtual machines to the network your host is joined. On Windows 10, you will get a default switch to connect your virtual machines. If this is not enough or you want to leverage the NAT VM Switch on a Hyper-V server, you can use the following commands to create a VM switch and NAT rule.
You can read more about the Hyper-V NAT networking here.
Run Windows and Linux Containers on Windows 10
Containers are one of the hot technologies right now, with Docker Desktop for Windows you can run them on your Windows 10 machine. In the background, Windows uses Hyper-V technology to apply additional isolation between the container and the host operating system, so-called Hyper-V Containers. This feature also allows you to run Windows and Linux containers on Windows side by side, without the need of running a full Linux VM on Windows 10.
PowerShell Direct & HVC
If you want to interact with your virtual machine running on Windows 10, you can use the Hyper-V Manager and the console to interact with the operating system directly. However, there are also two other options that allow you to manage and access the VMs using the command line. PowerShell Direct lets you create a PowerShell remoting session to the virtual machine using the VM Bus, so no networking is required. The same applies to Linux virtual machines and the HVC tool, which allows you to create an SSH connection directly into the VM. Both options also allow you to copy files to and from virtual machines.
This is extremely handy if you set up some automation, and you need to run some commands within the virtual machine.
Windows Sandbox
Windows Sandbox is a new feature in Windows 10 and was released in version 1903. Windows Sandbox uses Hyper-V technology to provide you with a Windows 10 Sandbox. The Sandbox allows you to spin up an isolated, temporary, desktop environment where you can run untrusted software. The sandbox is great for demos, development, testing, troubleshooting, or if you are dealing with malware. If you close the sandbox, all the software with all its files and state are permanently deleted. It is a Windows 10 virtual machines, with the advantage that it is built into Windows 10, so it leverages the existing OS, which gives you faster startup, less footprint, better efficiency, and easier handling, without losing security.
The Windows Sandbox experience can also be customized with configuration files. So, you can add additional software and tools to your Windows Sandbox. You can read more about Windows Sandbox and how you create the configuration files here.
Windows Defender Application Guard
This one might be not directly development related. However, I think we all have been here. We see a link, and we are not sure if this is a trusted site or if it is a malicious website. With Windows Defender Application Guard, we get an isolated browser, which protects us from malicious websites and software. If a user goes to an untrusted site through either Microsoft Edge or Internet Explorer, Microsoft Edge opens the site in an isolated Hyper-V-enabled container, which is separate from the host operating system.
You can enable Windows Defender Application Guard on Windows 10, using the following steps.
Hyper-V Battery Pass-through
This feature is more about convenience. If you are working and develop inside a virtual machine and you are running this virtual machine console in full-screen mode, you might not notice when your notebook runs out of battery. With the Battery Pass-through feature, the guest operating system inside the virtual machine knows about the battery status. The Hyper-V Virtual Battery feature is enabled by default and works with Windows and Linux virtual machines.
Nested Virtualization
Nested Virtualization lets you run virtualization in a virtual machine, basically like inception for virtual machines. With Hyper-V, you can run Hyper-V within a Hyper-V virtual machine. This is interesting for a couple of different scenarios. First, you can create a virtual Hyper-V host for testing and labs, or you even more important, you can run Hyper-V Containers or Windows Sandbox within a virtual machine. And another great thing about Nested Virtualization, it also works with virtual machines in Microsoft Azure.
To enable nested virtualization within a Hyper-V, you basically can follow this guide.
Visual Studio Emulator for Android
If you are using Visual Studio to build Android applications, I am sure you already used the Visual Studio Emulator for Android. This enables developers to use a hardware accelerated Android emulator, without needing to switch to Intel’s HAXM hypervisor, which gives them even more performance and speed.
How to set up Hyper-V on Windows 10
Now, as you can see, Hyper-V is a great developer tool and used for many different features. To Install Hyper-V, you have to check for the following requirements on your machine:
- Windows 10 Enterprise, Pro, or Education
- 64-bit processor with Second Level Address Translation (SLAT).
- CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs).
- Minimum of 4 GB memory.
For more information and troubleshooting, see Windows 10 Hyper-V System Requirements.
If you want to enable and install Hyper-V on Windows 10, you can run the following PowerShell command.
For more information on how you can install Hyper-V on Windows 10, you can check the following Microsoft Docs.
I hope this gives you an overview of why Hyper-V is great for developers and enables a lot of different features. If you have any questions, please leave a comment.