UPDATE: Windows 11 has been tested and works just as well, and the support will be added soon!
If you want to go adjust every little aspect of the VM to suit your needs, this section is for you. This guide works regardless of your Linux distribution.
NOTE: Using a recent version of Windows is recommended (anything after 20H1 or May 2020) as older revisions are known to have some issues, and hence are not mentioned in this guide.
You may need to enable AMD-V or Intel VT-x/VT-d depending on your CPU brand in your UEFI before going further.
THIS VARIES BETWEEN VARIOUS MOTHERBOARDS
Take a look at how to do it below:
How to enable Virtualization on your Motherboard
STEPS WILL VARY BETWEEN DIFFERENT MOTHERBOARD MANUFACTURERS
Please follow the steps to enable virtualization (SVM) in the BIOS for AMD motherboards:
1. Press Del
or F2
in the keyboard after power on, then go to the appropriate menu for AMD SVM/ Intel Virtualization (VT-x).
- Enable SVM (AMD)
- Enable VT-x and Intel Virtualization (Intel)
- OLD BIOS (Intel and AMD)
Instructions and media taken from Asus Forums.
If you have a laptop with UEFI, you can also check this video.
For Coreboot devices, refer to your manufacturer's instructions or check the official documentation here.
Boot into your preferred Linux OS and install the packages. You may search the packages in your package manager or compile them yourself.
Installing Dependencies
Note: Any Linux distribution will work just fine. You do need to install libvirt
, virt-manager
, qemu
, and other required dependencies.
# Debian & Ubuntu (Linux Mint, PopOS, ElementaryOS)
sudo apt install -y qemu qemu-kvm libvirt-bin libvirt-daemon libvirt-clients bridge-utils virt-manager
# Fedora based ditros
sudo dnf -y install qemu-kvm libvirt bridge-utils virt-install virt-manager
# Arch (Manjaro, Arco Linux, EndeavourOS)
sudo pacman -S --noconfirm qemu libvirt bridge-utils edk2-ovmf vde2 ebtables dnsmasq openbsd-netcat virt-manager
Instead of Systemd
, you can use OpenRC
, Runit
, SysVinit
as well.
# Enable Libvirt Service
sudo systemctl enable --now libvirtd
# Enable VM Console logging
sudo systemctl enable --now virtlogd
# Enable Virtual Network Bridge
sudo virsh net-autostart default
sudo virsh net-start default
Linux Kernel 5.4 LTS or newer is recommended
If you want to run Anti-Cheat games and use Winapps, you will need Windows 10 Pro/Pro N/Pro Workstation/Enterprise, as they have Hyper-V Support which is required.
- Download Windows 10 Pro ISO, and VirtIO Drivers (Stable)
You may even supply your own custom Windows Image (like Windows Ameliorated Edition)
Note: Place ISOs in /var/lib/libvirt/images/
to avoid permission issues.
Step by Step Guide - Click Me!
-
Open Virt Manager from your applications menu or type
virt-manager
in terminal. -
Click on the ➕ icon or the first icon in Virt Manager to create a VM.
- Select the Windows 10 ISO that you downloaded earlier, and choose the OS from the list if it isn't detected automatically.
- Allocate Memory and CPUs as per requirement.
-
Either create a new disk or create one as big as you want, and later select the disk here. You can enter any directory you wish, as well as how big you want it to be.
-
Enter this command to create a disk.
qemu-img create -f qcow2 /var/lib/libvirt/images/Windows10Vanilla.qcow2 1024G
- Check
Customize configuration before install
and click Finish.
- In the Overview section, Select
OVMF_CODE.fd
in Firmware.
-
In the CPU section, check
Copy host CPU configuration
if you aren't planning to make a Stealth VM, andhost-passthrough
otherwise. -
You may manually set
CPU Topology
if you know the exact layout of your CPU.
for example: Ryzen 5 3600 has
6 Cores
,12 Threads
and is only available in1 Socket
motherboards.
- In the Memory section, enter
Current allocation = 1024
to make initial RAM usage less.
- In SATA Disk section, Change the
Disk Bus
toVirtIO
to make operations faster by reducing overhead.
- In NIC section, Change the
Device model
toVirtIO
to enable Virtual Network Bridge for interfacing between VM and Host.
- Click Add Hardware and select the Storage section to add VirtIO Drivers ISO and change the
Device type
toCDROM device
and click Finish.
-
In the Boot Options section, select Windows ISO CDROM and VirtIO Disk that we created earlier, and check 'Enable boot menu'.
-
Finally, Click
Begin Installation
to save and start the VM.
If you encounter an OVMF/edk2 problem, check out OVMF Fix
Or you can enter the following command in terminal (only applicable this VM)
Ubuntu/Debian ➜
sudo cp /usr/share/OVMF/OVMF_CODE.fd /var/lib/libvirt/qemu/nvram/Windows10-default_VARS.fd
Fedora ➜
sudo cp /usr/share/edk2/ovmf/OVMF_CODE.fd /var/lib/libvirt/qemu/nvram/Windows10-default_VARS.fd
Arch ➜
sudo cp /usr/share/ovmf/x64/OVMF_VARS.fd /var/lib/libvirt/qemu/nvram/Windows10-default_VARS.fd
- Click inside the VM Window and press any key when asked.
- Select your language and keyboard input and click Next.
- Enter your product key now, or you can skip and enter your product key after installation.
- Selecting Windows 10 Pro N will install Windows 10 Pro without extra bloat.
Note: Choose Windows 10 Pro XXX or Enterprise if you need Hyper-V for Stealth VM.
- Select Custom Install (because the other one is useless)
- Click on Load Driver to install disk drivers.
- Double-Click on CD Drive virtio-win ➜ amd64 ➜ w10 and click OK.
- Just click Next to select the default one.
- Select
Unallocated Space
and click Next to begin the installation.
-
After installation, Windows will boot normally and you will need to set up your user account and password.
-
Avoid Microsoft Sign in if you can at all 😉
There usually isn't much that needs to be done for optimizing Performance in VM, but there are a couple of things that need to be taken into consideration for more than just a basic VM.
-
CPU Pinning for better CPU Allocation.
-
Huge Memory Pages for less overhead on systems with lot of memory allocation.
-
Other Small issues that do come from time to time.
Check out this video by SomeOrdinaryGamers for an easy tutorial on the same.
TLDR;
Writen Guides:
Video Guides:
- TechTeamGB Ubuntu NVIDIA Passthrough
- SomeOrdinaryGamers' Arch NVIDIA Passthrough
- Level1Linux Fedora Passthrough
For laptops, see Laptop Compatibility
Ideally you need to have 2 GPUs (one dedicated and one integrated) in order to access Windows as well as Linux desktop simultaneously, by using 2 monitors or switching the display output on one monitor.
However, if you are living in the world after 2020, I know your pain and why you have only one (or possibly none) GPU.
You might be in one of the following situations:
- You have ONLY one GPU, either discrete (NVIDIA/AMD RX) or iGPU (Intel/AMD Radeon)
- You have a discrete GPU (NVIDIA/AMD) + iGPU (Intel UHD/AMD Radeon)
- You have two discrete GPUs (then integrated graphics don't matter)
Refer the following sections according to your current system specifications. If your system has,
- SomeOrdinaryGamers' Single GPU Passhrough Video (NVIDIA)
- Fedora 34 Single GPU Passthrough on Level1Forums
- joeknock90 central repository
NOTE: Before you passthrough your GPU, make sure you enable your integrated graphics and set it to default in UEFI/Coreboot first, or else you won't be able to view your Linux Host.
In the past, it was required that you have two different GPUs (typically AMD + NVIDIA), but that's not the case anymore!
NOTE: The GPU used by the VM will be unavailable for the Linux System for use. Using the iGPU/low-cost GPU for the Linux system is recommended.
If you want to be able to use GPU Accelerated Applications (like Video Games, Adobe CC, etc) on a Windows VM without dedicating an entire monitor to Windows VM, check out the Looking Glass Project:
- Looking Glass - An extremely low latency Memory-to-Memory frame copy from the Guest to Host.
- Level1Techs Video - It has gotten better than what this video demonstrates!
NVIDIA's driver 465 and newer support GPU Passthrough to a Windows Guest on a Linux Host.
Check out LinusTechTips' Video, Wendell's Video and SomeOrdarinaryGamers' Video to get an idea about what could be possible down the line.
NOTE: NVIDIA still doesn't support SR-IOV so you will need an iGPU or a separate GPU if you want to be able to access the Linux Host.
If you don't want to use a second GPU, check out Single GPU Passthrough
Check Out NVIDIA GRID on GeForce and Quadro GPUs, NVIDIA's Proprietary alternative to SR-IOV.
You can read the Community made Wiki.
So if you need to passthrough an NVIDIA or AMD GPU without making it obvious that you are using a VM, add the following lines to your XML.
1. List all VMs
sudo virsh list --all
2. Edit the VM config
- Replace
Windows10
with the name shown in the previous step.
sudo virsh edit Windows10
3. Enter the following text between the already existing sections
...
<features>
...
<hyperv>
...
<vendor_id state="on" value="randomid">
</hyperv>
<kvm>
<hidden state="on"/>
</kvm>
...
</features>
For any issues not just limited to the following, check the following sections on the Arch Wiki.
- Unisolated IOMMU Groupings
- Problems with vfio-pci loading correctly
- Using a non-EFI image on EFI based VM
- Passing through a device that does not support resetting via kernel
According to the image above, if you have a MUXless laptop, it is a little tricky to dedicate your GPU to a VM and have its own separate display, because the GPU doesn't connect to the HDMI/DisplayPort Port directly, and instead uses the iGPU as a bridge to the laptop screen. Read more about it on this post in Level1Forums
You might be able to get around this by passing the iGPU to the VM, as shown here
You can still get past through this sometimes like this reddit post mentions, using an ROG Zephyrus G14 w/ RTX 2060.
Sometimes on Optimus/Max-Q laptops, NVIDIA wants to check for the battery info in Windows or else it returns Code 43.
If you experience that issue, check out the SSDT Workaround on ArchWiki.
If you still get a Code 43, perhaps batmanfeynman's post or alterNERDtive's post could help.
- For Polaris, Vega and Gen1 Navi Reset fix, installing vendor-reset is enough thanks to gnif.
- For RX 5000, check out Navi Reset Bug Kernel V2
- Also see the recent Pop! OS 20.10 VFIO 5700XT post
If you need to mask your VM from checks that a few programs do to restrict users from using certain programs inside a VM for various reasons (like Video Games), then this section is for you.
It goes over running DRM/Anti-Cheat games under VMs that have built in VM detection techniques.