Virtualize Windows 11 with Linux and KVM

You need a iso installation file from windows from https://www.microsoft.com/en-us/software-download/windows11
Select “Create Windows 11 Installation Media”. Execute and select “ISO file”.

In Linux debian pure text configuration, no desktop, you need to create a bridge device from your network card for direct internet access.
Install the bridge utils with “apt install bridge-utils”. Edit your network cards with “nano /etc/network/interfaces”. Find your network card, in my case it’s the card for the internal network enp2s0.

allow-hotplug enp2s0
iface enp2s0 inet manual
iface enp2s0 inet6 manual
auto br0
iface br0 inet static
        address 192.168.1.1
        netmask 255.255.255.0
        bridge_ports enp2s0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
iface br0 inet6 static
        address 1234:1234:1234:1235::1
        netmask 64
        autoconf 0
        accept_ra 1

You have to change more if you got a dhcp-server, samba and rad running:

nano /etc/default/isc-dhcp-server

INTERFACESv4="br0"
INTERFACESv6="br0"

nano /etc/samba/smb.conf

interfaces = br0

nano /etc/radvd.conf

interface br0
{
....

Install the kvm environment without any graphic tools but with uefi and tpm2 support:

apt install --no-install-recommends qemu-system libvirt-clients libvirt-daemon-system virtinst qemu-utils ovmf swtpm-tools

With “virt-install –osinfo list” you can see the supported operating systems.
For windows only ” virt-install –osinfo list | grep win”.

To install Windows 11 with 5gb ram, 2 cpus and a 200 gb harddisk and vnc access:

virt-install --name Windows --memory 5120 --disk path=/mnt/virt/windows.img,size=200 --cdrom /mnt/data/ISOs/Windows_11_23H2.iso --vcpus 2 --os-variant win11 --network bridge=br0 --noautoconsole --graphics=vnc,port=5901,listen=0.0.0.0 --video virtio --console pty,target_type=serial --noautoconsole --check all=off --hvm --features kvm_hidden=on,smm=on --tpm backend.type=emulator,backend.version=2.0,model=tpm-tis --boot uefi

If you don’t want to hide the kvm hypervisior signature for the guest remove:
kvm_hidden=on

In case of problems delete everything of the machine:

virsh
list --all
destroy <number>
undefine Windows / or undefine --nvram Windows
exit

To get the vnc port number (should be :1):

virsh vncdisplay Windows

Use a vnc viewer like https://www.realvnc.com/en/connect/download/viewer/ to finish the installation. You have to be quick after install virt-install otherwise it boots in the uefi menu.

To start and autostart the machine at boot:

virsh
list --all
start Windows
autostart Windows

You find virtio driver for windows here: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/

You have to activate Remote Desktop in Windows to gain access without vnc.

After installation finished remove the vnc access for security reasons:

virsh
edit Windows
remove
    <graphics type='vnc' port='5901' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

Remove the cdrom image:

virsh
edit Windows
remove
   <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/mnt/data/ISOs/Windows_11_23H2.iso'/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

As little example how to install linux with a fixed ethernet hardware address:

virt-install --name Linux --memory 1024 --disk path=/mnt/virt/linux.img,size=40 --cdrom /mnt/data/ISOs/debian-12.4.0-amd64-netinst.iso --vcpus 1 --os-variant debian11 --network bridge=br0,mac=52:54:00:5E:3A:43 --graphics=vnc,port=5901,listen=0.0.0.0 --check all=off --hvm