#!/bin/sh # # Creates a Windows server KVM using LVM. # Use ssh forwarding to access the VNC display to complete the Windows installation, like ssh example.host -L 56681:127.0.0.1:56681 # Once connected with VNC, browse for the viostor driver # # In this example, both network bridges on the host will be available in the Windows VM. # NAME=desktop RAM=4096 CPU=2 IMAGE=win-server-2019.iso VIRTIO_IMAGE=virtio-win.iso SIZE=50G VNC_PORT=56681 VARIANT=win2k16 VG=vg0 MAC=02:00:00:d1:78:d9 lvcreate -L $SIZE -n lv_vm_$NAME $VG virt-install --connect qemu:///system --arch=x86_64 -n $NAME -r $RAM --vcpus=$CPU \ --mac=$MAC \ --cdrom /var/lib/libvirt/images/$IMAGE \ --disk path=/dev/$VG/lv_vm_$NAME,bus=virtio \ --disk path=/var/lib/libvirt/images/$VIRTIO_IMAGE,device=cdrom \ --graphics vnc,listen=127.0.0.1,port=$VNC_PORT \ --noautoconsole \ --os-type windows \ --os-variant=$VARIANT \ --network=bridge:br0,model=virtio \ --network=bridge:br1,model=virtio \ --accelerate \ --noapic