Virtualization has transformed the way we manage and deploy resources. Whether on the cloud or on-premise, virtualization technologies enable us to maximize resource utilization, enhance scalability, reduce costs, and strengthen security.
Hyper-V is a widely used virtualization product from Microsoft that can seamlessly run multiple, independent virtual machines on any computer. In this article, we will provide a comprehensive guide to Hyper-V, covering its features, how it compares to VMware, and how to enable and manage it on Windows Server 2019.
Virtualization is the process of creating multiple isolated virtual resources from a single physical resource. In simple terms, virtualization allows a physical computer to run many virtual computers, with each virtual computer getting its own dedicated network, memory, storage, and operating system (OS).
Virtualization does this by using a special software called a hypervisor. The hypervisor acts as an abstraction layer between the virtual computers (or machines) and the physical resources. It manages the allocation and distribution of virtual resources to the virtual computers and ensures that they do not interfere with each other.
Docker containers and virtual machines (VMs) are two popular types of virtualization. Docker containers are lightweight virtualization solutions that package an application and its dependencies into a single image. VMs are more heavyweight virtualization solutions that allow you to run entire operating systems in isolated environments.
Virtualization has several benefits, including:
Hyper-V is a hypervisor developed by Microsoft that lets you create, deploy, and manage virtual machines on a Windows server. It offers several security, performance, and networking features that were not offered by Microsoft's older virtualization products, such as Microsoft Virtual Server and Windows Virtual PC.
Hyper-V virtualizes all the hardware resources of a physical computer and shares them across different virtual machines. The physical computer on which Hyper-V runs is known as the host. The virtual machines running on the host are known as guest VMs.
Each Hyper-V virtual machine operates as if it were a separate physical computer, with its own operating system, memory, storage, network, and processor. This isolation makes it possible to run applications with different kernel needs on the same computer. For example, you can run a C++ application inside a CentOS 7 VM, and a Java application inside a Windows Server VM, on the same physical computer.
The latest versions of Hyper-V can also be enabled on certain Windows 10 versions, including Windows 10 Enterprise, Windows 10 Pro, and Windows 10 Education. To run Hyper-V, your system must meet the following minimum requirements:
Hyper-V uses a virtual switch and a virtual networking adapter for networking. The virtual switch is a Layer-2 Ethernet switch with many pre-built features for traffic segmentation, monitoring, and security. The network adapter binds with a port on the virtual switch, which allows a VM to start networking.
To set up networking, administrators can create a virtual switch during the Hyper-V installation. This switch can then be attached to VMs as they are provisioned. When a switch is associated with a VM, Hyper-V automatically adds a network adapter to that VM.
It’s worth noting that a single virtual switch can be associated with multiple VMs. The switch enables the VMs to share the same network resources, and communicate with each other and the external network, as needed.
Hyper-V offers different kinds of virtual switches:
Hyper-V also supports native Network Address Translation (NAT) for virtual machines. NAT allows multiple VMs to use the host’s IP address when connecting to external networks. To implement NAT, you must create a NAT virtual network and connect it with your VM’s internal switch.
VMware is a company that offers a wide range of virtualization products, including vSphere, VMware Workstation, and VMware ESXi. Hyper-V and VMware are the two leading virtualization platforms. Both platforms offer a wide range of benefits, but there are also some key differences between them.
When deciding between physical servers (bare metal) and Hyper-V/VMWare virtual machines, it's important to weigh the pros and cons of each option. In this section, we'll explore the key considerations to help you make the right call.
When you use bare metal, your workloads are run directly on the physical servers. Each server generally runs a single operating system, and you have maximum control over the hardware. This approach offers the highest levels of isolation, as each server can operate independently.
With virtual machines, you run multiple instances of operating systems on a single physical server. All the VMS share the hardware resources of the server, including the CPU, memory, network, and storage. Even though VMs do provide isolation between workloads, it’s not as strict as with bare metals.
When you use bare metal, each server is dedicated to a particular task or application. While this does provide maximum performance for that particular workload, it can result in underutilized hardware, as one server often doesn’t use all of its available resources.
VMs are much more resource-efficient as they allow you to run multiple workloads on a single physical server. This efficient resource usage is one of the key benefits of virtualization. Moreover, users can dynamically allocate and share resources for VMs, based on demand, which makes them a flexible solution as well.
Scaling with bare metal generally involves adding more physical servers. This process is much less flexible and slower compared to scaling VMs, as it often requires the purchase, installation, and configuration of new hardware.
VMs offer greater scalability. You can easily spawn, clone, or migrate VMs to cater to changing demands, often without the need for additional physical hardware. This scalability is a primary reason why virtualization is a popular choice for cloud computing and data centers.
Managing, monitoring, and maintaining physical servers can be more labor-intensive. Updates, backups, troubleshooting, and auditing may require more effort, especially for large-scale deployments.
VMs are inherently easier to manage. Virtualization platforms, like HyperV and VMWare, provide tools for central management, snapshot backups, seamless migration, and troubleshooting. Updates and maintenance can be more streamlined, as changes can be made centrally (at the virtualization layer).
The deployment of bare metal servers may involve higher upfront costs as you will need dedicated servers for different workloads. However, in some cases, it can be more cost-effective for specific high-performance applications that require dedicated resources, e.g. a data warehouse.
In terms of hardware needs and utilization, VMs can be far more cost-effective compared to bare metal. They allow you to make the most of your existing hardware and provide flexibility to scale resources as needed.
Hyper-V offers an array of features related to the deployment, networking, management, security, operations, and migrations of VMs.
Hyper-V is shipped as a part of most Windows versions. You only need to install and enable the Hyper-V role to start creating and running virtual machines. We will show you two ways to enable the role on Windows Server 2019: through the Server Manager and PowerShell.
Before you begin, check if your system meets the virtualization requirements. You can do this by running this command on PowerShell:
Navigate to the "Hyper-V Requirements" section at the end of the output. On a supported system, you should see the following lines:
Hyper-V Requirements: VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes
Second Level Address Translation: Yes
Data Execution Prevention Available: Yes
We’ll be using the Install-WindowsFeature cmdlet to install and enable Hyper-V. Follow these steps:
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
Install-WindowsFeature -Name Hyper-V -ComputerName
The server should now restart with Hyper-V enabled.
Once the installation finishes, you should be able to see the new server in the “All Servers” page in Server Manager.
Now that we have installed and enabled the Hyper-V role on our server, we can use the Hyper-V manager to create a virtual machine. Follow these steps:
Now that we have created our first virtual machine on a Hyper-V-powered virtualized resource, let's explore how to perform some common administrative operations using the Hyper-V manager and PowerShell.
We can use PowerShell to stop a virtual machine that’s malfunctioning or unresponsive. The Stop-VM command lets you shut down or turn off a virtual machine using its name. For example, running the following command from the guest system will shut down a virtual machine with the name SampleVM:
Stop-VM -Name SampleVM
You can also use the -Force option to force a shutdown after giving the VM 5 minutes to save its data.
Stop-VM -Name SampleVM -Force
To simply turn off the machine, use the -TurnOff option. This is similar to unplugging a physical computer and can lead to the loss of unsaved data.
Stop-VM -Name SampleVM -TurnOff
It’s possible to import/export Hyper-V VMs using the PowerShell or the Hyper-V manager.
When using the Hyper-V manager, right-click the VM and choose Export. Then choose the directory to store the exported file, and hit Export.
From the PowerShell, you can use the Export-VM cmdlet to export a VM. For example, the following command will export a VM named SampleVM to the directory D:\export.
Export-VM -Name SampleVM -Path D:\export
When using the Hyper-V manager:
From the PowerShell, you can use the Import-VM cmdlet to import a VM. For example, the following command will import a VM from the given path and copy its files to the default directories. (Make sure to replace the path and the name of the export file)
Import-VM -Path 'D:\export\2B912EC3-F1F0-4FDF-B98E-29CAD592C95B.vmcx' -Copy -GenerateNewId
Follow these steps to create a new external virtual switch for your VMs using PowerShell:
$adapter = Get-NetAdapter -Name 'Ethernet Adapter 2'
New-VMSwitch -Name "External Virtual Switch 2" -AllowManagementOS $True -NetAdapterName $adapter.Name
Hyper-V makes it easy to create checkpoints. A checkpoint captures the state of a virtual machine, allowing you to roll back to a previous state if needed. Here’s how to create a checkpoint using the Hyper-V manager:
You can migrate a running virtual machine using the Hyper-V Manager in just five simple steps:
The Hyper-V manager offers some basic metrics about the health and status of a virtual machine, including uptime, CPU usage, assigned memory, and status. Microsoft also offers other native tools to track and monitor Hyper-V VMs in real time.
For example, the Measure-VM cmdlet can be used to fetch data related to network traffic, disk usage, processor usage, and more. The Measure-VMReplication cmdlet shows stats related to replication. The Measure-VMResourcePool cmdlet reports resource utilization data for pools of virtual machines.
If you want a dedicated, all-in-one tool to monitor Hyper-V, you should check out Site24x7’s Hyper-V monitoring solution.
PowerShell Direct is a handy way for remote management of Hyper-V VMs. Follow these steps to remotely access and manage a VM using PowerShell:
Enter-PSSession -VMName TestVM
That’s it! You can now run commands directly on the connected VM. Once you are done, use the Exit-PSSession to log out of the session.
Hyper-V is a leading virtualization software that enables you to build fault-tolerant and agile virtualized infrastructures. It is easy to use and offers a wide range of built-in features and tools for provisioning, deploying, managing, and scaling virtual machines.
Write for Site24x7 is a special writing program that supports writers who create content for Site24x7 “Learn” portal. Get paid for your writing.Apply Now