How to run a Windows virtual machine on Incus on Linux

Incus is a manager for virtual machines and system containers.

A virtual machine (VM) is an instance of an operating system that runs on a computer, along with the main operating system. A virtual machine uses hardware virtualization features for the separation from the main operating system. With virtual machines, the full operating system boots up in them. Therefore, it is possible to run Windows in a virtual machine, even if your host is Linux.

A system container is an instance of an operating system that also runs on a computer, along with the main operating system. A system container, instead, uses security primitives of the Linux kernel for the separation from the main operating system. You can think of system containers as software virtual machines. The system containers reuse the running Linux kernel of the host, therefore you can only have Linux system containers, any Linux distribution.

In this post we are going to see how to create an Incus virtual machine with Windows.

Table of Contents

Updates

Update #5 [2024-06-05]: Added parameter --windows-arch=amd64 to the distrobuilder command (be explicit with the architecture). Thanks Brian!

Update #4: In Bonus Material #4. How to mount a directory from the host to the Windows VM.

Update #3: In Bonus Material #3. If the Windows VM crashes, there are two workarounds.

Update #2: In Bonus Material #2. Instead of keeping the Windows ISO file on your host, you can place it in the Incus storage pool.

Update #1: In Bonus Material #1. You can create an Incus profile that you can easily use when you want to create a Windows VM.

Prerequisites

  1. You should have a system that runs Incus.
  2. A Windows ISO file or enough bandwidth to download one.
  3. A system with support for hardware virtualization so that it can run virtual machines.

Cheat sheet

This is a summary of the commands. You are supposed to consult this section after you thoroughly read the post.

sudo snap install distrobuilder --classic
sudo distrobuilder repack-windows --windows-arch=amd64 Win11_23H2_English_x64v2.iso Win11_23H2_English_x64v2.incus.iso
incus init win11vm --empty --vm
incus config device override win11vm root size=55GiB
incus config set win11vm limits.cpu=4 # MUST SEE BONUS MATERIAL #3.
incus config set win11vm limits.memory=6GiB # Should be OK with 4GiB as well.
incus config device add win11vm vtpm tpm path=/dev/tpm0
incus config device add win11vm install disk source=/home/myusername/Downloads/Win11_23H2_English_x64v2.incus.iso boot.priority=10
incus start win11vm --console=vga
incus console win11vm --type=vga
incus config device remove win11vm install

Downloading a Windows ISO file

You can download Windows ISO files from Microsoft, for example, at https://www.microsoft.com/en-us/software-download/ In my case I am selecting Windows 11. This site offers ISO images for Windows 8.1, Windows 10 and Windows 11. However, currently, the distrobuilder companion for Incus can only prepare ISO images for Windows 11, Windows 10, Windows Server 2019, Windows Server 2012, Windows server 2016, Windows Server 2019 and Windows Server 2022.