Tutorial: how to create a Windows 11 VM

With the help of Davide Cavalca in the Fedora Asahi Matrix room I was able to get Windows 11 IoT to work. But the instructions were a bit bare bones, so I made a more complete tutorial here. In the end you should have a working Windows VM.

Note that this is the IoT variant of Windows 11, not the full version. The full version probably needs some hacks to get past the minimum requirements Windows has. I prefer to avoid bloat so I use the IoT version.

Here are the steps:

  1. Create a new directory (I’m using windows) for the files we’ll be using.
  2. Download a Windows ISO: Please select your Windows 11 IoT Enterprise LTSC download (pick the ARM64 one).
    Rename this file to windows-11-iot.iso.
  3. Download the virtio-win ISO: Driver installation · virtio-win/kvm-guest-drivers-windows Wiki · GitHub
    Rename this file to virtio-win.iso.
  4. Create a new virtual disk (you can change the size as you wish, the install described here leaves about 6GB of space after installation):
    $ qemu-img create -f qcow2 win11.qcow2 25G
    
  5. Create a file win11.sh with the following contents, and use chmod +x win11.sh to make it executable:
    #!/bin/sh
    
    performance_cores=$(awk '
      /^processor/ { proc=$3 } 
      /^CPU part/ {
        if ($4 == "0x023" || $4 == "0x025" || $4 == "0x029" || $4 == "0x033" || $4 == "0x035" || $4 == "0x039")
          procs=procs ? procs","proc : proc
      } END { print procs }
    ' /proc/cpuinfo)
    
    taskset -c "$performance_cores" \
      qemu-system-aarch64 \
        -display sdl,gl=on \
        -cpu host \
        -M virt \
        -enable-kvm \
        -m 2G \
        -smp 2 \
        -bios /usr/share/edk2/aarch64/QEMU_EFI.fd \
        -hda win11.qcow2 \
        -device qemu-xhci \
        -device ramfb \
        -device usb-storage,drive=install \
        -drive if=none,id=install,format=raw,media=cdrom,file=windows-11-iot.iso \
        -device usb-storage,drive=virtio-drivers \
        -drive if=none,id=virtio-drivers,format=raw,media=cdrom,file=virtio-win.iso \
        -object rng-random,filename=/dev/urandom,id=rng0 \
        -device virtio-rng-pci,rng=rng0 \
        -audio driver=pipewire,model=virtio \
        -device usb-kbd \
        -device usb-tablet \
        -nic user,model=virtio-net-pci
    
  6. Now run ./win11.sh. A QEMU window pops up. After going through some boot screens, it should show “Press any key to boot from CD or DVD…”. Press any key to boot Windows (quickly, because otherwise you’ll end up in a UEFI console).
  7. Windows should now be booting, and you should end up in the Windows 11 setup. Most of this is straightforward, but there is one thing to be aware of:
    • In the “Select location to install Windows 11”, no drives are shown. Fix this by clicking “Load Driver”, “Browse”, expand the virtio-win drive, and select viostor → w11 → ARM64. Click OK. Select the “Red Hat VirtIO SCSI controller” that appears, and click install.
  8. During the installation, the VM will reboot a few times. Don’t do anything, just let it happen.
  9. After installation you’ll end up in the first boot wizard (to configure location, keyboard, etc).
    • In the “Let’s connect you to a network”, click “Install driver”, open the virtio-win drive, navigate to NetKVM → w11 → ARM64, and click “Select folder”. Wait a few seconds, and the network adapter should appear. You can now continue.
  10. After completing the installation, you should have a working Windows 11 install!

Shut down the VM as usual to not make Windows scared (don’t just exit the win11.sh script). To boot it again, simply run the ./win11.sh script again.

After installation, you can remove the two ISOs and remove the following 4 lines from the win11.sh script:

    -device usb-storage,drive=install \
    -drive if=none,id=install,format=raw,media=cdrom,file=windows-11-iot.iso \
    -device usb-storage,drive=virtio-drivers \
    -drive if=none,id=virtio-drivers,format=raw,media=cdrom,file=virtio-win.iso \

Updates of this tutorial:

  1. Updated to use SDL screen, which allows for an 800x600 screen that makes installation a whole lot easier, and added instructions how to remove the installation ISOs.
  2. Updated instructions to add networking.
2 Likes

https://sysguides.com/install-a-windows-11-virtual-machine-on-kvm

Would it make sense to add this tutorial to the asahi docs?

Oh that would be a good idea! If someone wants to do this: feel free to use my post above as a starting point.

For those wanting to SSH into the Windows VM (like me):

  1. Modify the QEMU command line, replace -nic user,model=virtio-net-pci with -device virtio-net-pci,netdev=net0 -netdev user,id=net0,hostfwd=tcp::5555-:22 to forward port 5555 to port 22 in the VM (you can pick another port if you like).
  2. Start “Optional Features”, click “View features”, search for OpenSSH Server, and install it. (This takes a while).
  3. Allow port 22 through the Windows firewall, see this StackOverflow post.
  4. Start “Services”, look for “OpenSSH SSH Server”, and start it (right click → start). Also, right click on it, go to properties, and set the startup type to automatic so it always starts at boot.
  5. Now you can SSH into your Windows system using ssh yourusername@localhost -p 5555!
  6. If you want to log into the system using public-key authentication, you can put the public key in C:\ProgramData\ssh\administrators_authorized_keys (assuming your account is an administrator account).
1 Like

Why just don’t you add a pull request with all that information to GitHub - AsahiLinux/docs: Asahi Linux documentation :wink: ?

These instructions works only for W11 IOT? Full Win11 iso complains that the “PC” does not meet win11 system requirements. Is the problem secure boot?

EDIT: anyway… IOT version appears as normal win11 installation :+1:

Thanks for this guide, it was easy to follow and I’ve successfully set up the VM. USB passthrough works with a couple of devices I’ve tested now.
I can’t seem to get any graphics besides RAM framebuffer to work. Performance seems really usable and I’m interested to see what I can run with this.

You can also use these instructions for the full version of Windows 11. The steps are mostly the same, though you will definitely need a bit more storage (at least 5GB more, I recommend a bit more than that). The main difference is that you need to do some register modifications when the installer starts. See: How to Bypass Windows 11's TPM, CPU and RAM Requirements | Tom's Hardware

In short, on the first screen of the installer:

  • Press Shift+F10 (or more likely Shift+Fn+F10 on an Apple keyboard).
  • Type regedit in the terminal that appears.
  • Navigate to HKEY_LOCAL_MACHINE\SYSTEM\Setup
  • Create a new key named LabConfig, and navigate to it. Now you’re in HKEY_LOCAL_MACHINE\SYSTEM\Setup\LabConfig.
  • Create 3 new DWORD values and set them all to 1: BypassTPMCheck, BypassSecureBootCheck, BypassRAMCheck. (I guess the BypassRAMCheck might not be necessary if you give the VM enough RAM but it won’t hurt).
  • Close both windows (regedit and the terminal) and continue installing as usual.

It’s also a bit more difficult to create a local account (instead of signing in to a Microsoft account), see here for a way around that: How to Install and Log In to Windows 11 Without a Microsoft Account | Tom's Hardware

Personally I prefer the IoT version. It does everything I need while being smaller (in VM size) and not having all the extra apps that I won’t be using anyway and only get in the way - just the bare minimum like Notepad, File Explorer, and Edge.

1 Like