Skip to content

Instantly share code, notes, and snippets.

@hoonsubin
Last active September 3, 2021 10:13
Show Gist options
  • Save hoonsubin/671b3293ba9cdc3ebb6d9ffd64a0f5a4 to your computer and use it in GitHub Desktop.
Save hoonsubin/671b3293ba9cdc3ebb6d9ffd64a0f5a4 to your computer and use it in GitHub Desktop.
How to install Hyper-V on Windows 10 and 11

Introduction

I know it's hard to believe, but there are situations where you must use Windows as the host machine for development purposes. In an ideal world, we can use VirtualBox on a Hyper-V-enabled host without performance downgrade. But we don't live in a perfect world (unless you have money to buy VMware), so we'll have to work with what we got. If you still want to play games on your Windows host, use WSL2, and run a full GNU/Linux environment, you should give Hyper-V a shot. You can learn more about Microsoft Hyper-V from the following links:

System Requirements

Hyper-V is available in 64-bit version of Windows 10 Pro, Enterprise, and Education. Hyper-V requires Second Level Address Translation (SLAT) -- present in Intel and AMD's current generation of 64-bit processors. You can run 3 or 4 basic virtual machines on a host that has 4GB of RAM, though you'll need more resources for more virtual machines. On the other end of the spectrum, you can also create large virtual machines with 32 processors and 512GB RAM, depending on your physical hardware.

Although this document does not provide a complete list of Hyper-V compatible hardware, the following items are necessary:

  • 64-bit Processor with Second Level Address Translation (SLAT).
  • CPU support for VM Monitor Mode Extension (VT-x on Intel CPUs, AMD-V on AMD CPUs).
  • Minimum of 4 GB memory. As virtual machines share the memory with the Hyper-V host, you will need to provide enough memory to handle the expected virtual workload.

The following items will need to be enabled in the system BIOS:

  • Virtualization Technology - may have a different label depending on motherboard manufacturer.
  • Hardware Enforced Data Execution Prevention.

(Source: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/hyper-v-requirements)

Enabling Hyper-V and Hyper-V Manager

  1. Enable the virtualization technology config supported by your motherboard and CPU (via the BIOS/UEFI settings).
  2. Create a new .bat file with the following script and run it as admin.
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hv.txt
for /f %%i in ('findstr /i . hv.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hv.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause
  1. Reboot your PC.
  2. Open the "Turn Windows features on or off" panel and ensure that the "Hyper-V" feature is checked.

windows-features

  1. If everything went right, your system should be able to use the "Hyper-V Manager" and "Hyper-V Quick Create" app.

hyper-v-manager

  1. Create a new virtual machine.

(Source: https://www.xda-developers.com/how-to-install-hyper-v-windows-11-home/)

And that is it! For your next steps, considering reading these articles:

pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hv.txt
for /f %%i in ('findstr /i . hv.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hv.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment