Skip to content

Instantly share code, notes, and snippets.

@4nd3r
Last active July 18, 2023 23:37
Show Gist options
  • Save 4nd3r/579830e5e08353ece05f009c1757987d to your computer and use it in GitHub Desktop.
Save 4nd3r/579830e5e08353ece05f009c1757987d to your computer and use it in GitHub Desktop.
#!/bin/sh -e
# Works on Debian Sid as of March 2021, YMMV :)
# Worth reading:
# man qemu-system
# less /usr/share/doc/ovmf/README.Debian
# https://wiki.debian.org/SecureBoot/VirtualMachine
# https://wiki.qemu.org/Documentation/Networking
# https://github.com/qemu/qemu/blob/master/docs/pcie.txt
# apt install qemu-system-x86 qemu-utils ovmf
# cp /usr/share/OVMF/OVMF_VARS_4M.ms.fd ~/Desktop/tmp/OVMF_VARS_4M.ms.fd
# qemu-img create -f raw ~/Desktop/tmp/windows.img 30G
# To boot from ISO, type "exit" in UEFI shell and use Boot Manager
# You probably can skip sudo if you add user to necessary groups
sudo qemu-system-x86_64 \
-enable-kvm \
-cpu host,hv-vapic,hv-spinlocks=8191,hv-time \
-smp 2 \
-m 4096 \
-machine q35,smm=on \
-global driver=cfi.pflash01,property=secure,value=on \
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE_4M.secboot.fd \
-drive if=pflash,format=raw,file=/home/ander/Desktop/tmp/OVMF_VARS_4M.ms.fd \
-drive format=raw,file=/home/ander/Desktop/tmp/windows.img \
-cdrom /home/ander/Downloads/Win10_20H2_v2_English_x64.iso \
-drive index=3,media=cdrom,file=/home/ander/Downloads/virtio-win-0.1.190.iso \
-netdev user,id=eth0,hostfwd=tcp:127.0.0.1:3389-:3389 \
-device virtio-net-pci,netdev=eth0 \
-usb \
-device usb-tablet \
-rtc base=localtime \
-device tpm-tis,tpmdev=tpm0 \
-tpmdev passthrough,id=tpm0,path=/dev/tpm0,cancel-path=/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment