How to Install and Configure Hyper-V

Hyper-V is next to ESX one the most used Hypervisors to run VMs. Hyper-V is available for free, and you can install Hyper-V on Windows Server and on Windows 10 and 11, allowing you to run and manage multiple VMs on your computer.

In this article, I will explain how to install Hyper-V on Windows Server and Windows 10/11, set it up, and how to create your first VM. I have also included some performance tips to get the most out of your Hyper-V enviroment.

Requirements

To run Hyper-V on your server or computer that are some requirements that you will need:

  • 64-bit process with SLAT (second-level address translation, (every i3, i5, i7, and i9 processor supports it, just like most AMD processors these days))
  • At least 4 GB of memory. More is better, I recommend getting at least 8Gb
  • Virtualization support turned on in the Bios or UEFI
  • VM Monitor Mode extensions
  • Hardware-enforced Data Execution Prevention (DEP)

You can easily verify if your hardware meets the requirements with a single command in PowerShell. The command systeminfo will show you all the important information about your system. If you scroll all the way down you will find the Hyper-V requirements and if they are met.

systeminfo
hyper-v requirements
Systeminfo results

Install Hyper-V on Windows Server

To install Hyper-V on a Windows server we will need to add the Hyper-V role to the Windows server. With the Hyper-V role also comes the Hyper-V Manager, which we need to actually create and manage the VMs. We have two options to add the role, we can use the Server Manager or enable the role with PowerShell.

Let’s first take a look at the Server Manager. This is installed by default on all Windows servers. You can find it in the start menu.

  1. Open the Server Manager
  2. Click on Manage > Add roles and Features in the top-right corner
  3. Click 3-times on Next to skip to Server Roles
  4. Select the Hyper-V role
  5. Click Add Features to the suggested features that are required for Hyper-V
Add Hyper-V Role
  1. Click Next (twice) to Virtual Switches
  2. Select at least one network adapter to connect your VM’s to your network (internet)
  1. If you want to do live migrations of VMs between Hyper-V hosts, then enable Virtual Machine Migrations. Otherwise, you can leave this off
  2. Select the location for your VMs in Defaults stores
  3. Click on Install to install Hyper-V

It can take a couple of minutes to complete the Hyper-V installation on your server. A restart is required as the final step the complete the installation.

Install Hyper-V with PowerShell

We can also install Hyper-V on a Windows server with PowerShell. Make sure that you have opened PowerShell with admin privileges (elevated) and run the following command to install the Hyper-V role and management tools:

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart

The PowerShell method won’t create a virtual switch in Hyper-V, which is needed to connect your VM’s to the internet. So we will need this create this later on.

Install Hyper-V with PowerShell
Install Hyper-V with PowerShell

Installing Hyper-V on Windows 10/11

You can also install Hyper-V on a computer with Windows 10 or 11, as long as your device meets the requirements for Hyper-V. To install Hyper-V on Windows we will need to add a Windows Feature:

  1. Open Start and type “Control Panel” and open it
  2. Open Programs and Features
  3. Click on Turn Windows features on or off
  4. Select Hyper-V
  5. Click on Ok to install Hyper-V
install hyper-v on Windows 10
install hyper-v on Windows 10

The computer needs to be restarted to complete the installation. You can also use this method to only install the Hyper-V management tools on your computer. The management tool can be connected to your Hyper-V server, allowing you to manage your VN’s from your own computer.

Setting up Hyper-V

If you have installed Hyper-V using PowerShell then we will need to configure a couple of settings in Hyper-V. Right-click on your Hyper-V server in the Hyper-V Manager and select Hyper-V Settings. Here you probably want to change the location of your Virtual disk and Virtual machines.

Creating a Virtual Switch

Next, we will need to create a virtual switch. There are three types of switches that we can create:

  • External – Connects the VMs to the physical adapter of your Hyper-V server and allows the VM’s to connect to other devices in your network and to the internet
  • Internal – Allows the VM’s to connect to each other and the Hyper-V server, but doesn’t map to your local network or the internet.
  • Private – Creates an internal network only for the VMs.

We are going to create an External switch, so our VMs can also access the internet:

  1. Right-click on your Hyper-V server and open the Virtual Switch manager
  2. Choose External
  3. Click on Create Switch
  4. Give the switch a name

Installing your first VM

With Hyper-V up and running, we can now install our first VM. To install a virtual machine we will need an ISO file with the OS that you want to install. For Windows Server 2022, you download the ISO files from the Microsoft Evaluation Center.

Open the Hyper-V Manager to create a new VM:

  1. Right-click on your Hyper-V server and choose New > Virtual Machine
  2. Click Next and give your VM a name. Check the location of the VM is correct
  3. Select Generation 2
  4. Assign Memory, a minimum of 1024MB for Win Server 2022 – If you want to get a decent performance, then assign 4GB of RAM to the server.
  5. Select your Virtual Switch to connect your VM to the network
  6. Create a new Virtual Disk. Make it at least 30GB for Windows 11 and Windows Server 2022
  7. Installation Options (optional) – here you can mount the ISO for the OS that you want to install. You can also do this later.
  8. Click on Finish to create your new VM
Create VM in Hyper-V

After your VM is created you can start the VM in the Hyper-V manager and use the connect option to open the display of the new VM.

Tips for Hyper-V

To get the best performance out of your Hyper-V server there are a couple of tips when it comes to your Hyper-V server and creating VMs:

1. Optimizing the Host

The first step is to optimize the Hyper-V host. For the host, we want to look mainly at the hardware and how it’s used:

  • Use the latest drivers
  • Remove unused roles from the Windows server
  • Use a separate disk array for your VMs
  • Use SSDs or NVMe disks in RAID-10 for the best performance

If you are using an antivirus on your host, then make sure that you exclude the VM files from the AV. Also, make sure that your host is excluded from any inventory tools that regularly scan the server.

2. Optimizing VMs

When creating the VMs keep the following points in mind to get the best performance:

  • Generation 2 VMs – The advantage of Gen 2 is that they are based on VMBUS and VPS architecture of the boot level. This increases the performance of the VM. Gen2 also allows the VM to be loaded over the SCSI controller, instead of the IDE controller
  • Don’t use VM Encryption – VM encryption decreases the performance of your VM
  • Use Static Memory – Make sure that you allocate enough memory and don’t use Dynamic Memory. The problem with dynamic memory is that Hyper-V tends to unallocate the RAM, which doesn’t do the performance any good.
  • vCPUs – Start with one vCPU and check the performance and CPU load in the VM. If it’s around 80% or higher, then add a second vCPU and test again. There is no need to assign 4vCPU’s if the VM doesn’t need them.
  • Fixed VHD disk – Fixed-size disks are faster than dynamically expanding disks. The problem with the latter is that they get fragmented, resulting in longer read and write times.

Wrapping Up

Installing Hyper-V is pretty straigt-forward these days, because it’s available as feature role in Windows. Make sure that you have enough memory installed in your Hyper-V to get the best performance.

I hope this article helped you installing Hyper-V, if you have any questions, just drop a comment below.

1 thought on “How to Install and Configure Hyper-V”

  1. Would be my preferred setup, Windows server with Hyper-V, but unfortunately there is no possibility to redirect USB devices for my Home Assistant setup 🙁

Leave a Comment

0 Shares
Tweet
Pin
Share
Share