Last active
December 5, 2023 05:27
-
-
Save trick77/1816c64b2a2dbcb6346459ff00fc8e4c to your computer and use it in GitHub Desktop.
Shell script to create a Windows server 2019 KVM using virt-install and LVM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment