Skip to content

Instantly share code, notes, and snippets.

@ArturiaPendragon
Last active February 22, 2022 10:27
Show Gist options
  • Save ArturiaPendragon/9330f47dffc002c8820a5e99956e1969 to your computer and use it in GitHub Desktop.
Save ArturiaPendragon/9330f47dffc002c8820a5e99956e1969 to your computer and use it in GitHub Desktop.

Installation Qemu + UEFI for Large Storage & Windows 2016, 2019, 2022 Datacenter Edition

Version pris en charge : Debian 11.1 - Hetzner @2022

Pré-requis:

apt-get update
apt-get install qemu-utiles qemu-kvm bridge-utils virt-manager qemu virt-viewer spice-vdagent

OVMF pour UEFI/GPT :

apt-get install ovmf

Crée une partition vide pour le serveur:

qemu-img create -f qcow2 -o preallocation=off winserver2.qcow2 64T

Placer les fichiers sur le serveur:

  winserver.iso
  virtio-win.iso

Lancer une première fois la VM (avec installation et ajouts du Réseau):

qemu-system-x86_64 -m 56475 -enable-kvm -cpu host -smp cores=2,threads=2,sockets=1 -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::3390-:3389 -drive file=winserver2.qcow2,if=virtio -usb -device usb-tablet -nographic -vnc :0 -drive file=winserver.iso,index=0,media=cdrom -drive file=virtio-win.iso,index=1,media=cdrom

Lancer une connextion VNC avec IP + MPD admin sur le port 5900, puis procédé à l'installation, charger ensuite le bon virtio (en fonction de la version de Windows Server (2k19)).

Convertir MBR en GPT dans Windows :

Lancer cmd en Admin et : mbr2gpt /convert /disk:0 /allowFullOs

Lancer la VM en production normale:

qemu-system-x86_64 -bios /usr/share/ovmf/OVMF.fd -m 56475 -enable-kvm -cpu host -smp cores=12 -device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp::33090-:3389,hostfwd=tcp::5521-:21,hostfwd=tcp::40001-:40001,hostfwd=tcp::40002-:40002 -drive file=winserver2.qcow2,if=virtio -usb -device usb-tablet -nographic

Listes des services actifs :

  • Bureau à distance : 33090 -> 3390
  • FileZilla Server : 5521 -> 21, 40001-40002 (PASV)
  • Ports à ouvrir dans le Firewall.

Tips:

qemu-img check winserver2.qcow2
qemu-img info winserver2.qcow2
qemu-img resize winserver2.qcow2 +2000G

Tips2: Si installer sur Hetzner ne pas oublier de débloqué la BP:

#!/bin/bash
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

echo "tcp_bbr" >> /etc/modules-load.d/modules.conf
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
modprobe tcp_bbr
sysctl -p

sysctl net.ipv4.tcp_available_congestion_control | grep -q bbr && echo "[+] BBR disponible" || echo "[-] BBR non disponible"
sysctl net.ipv4.tcp_congestion_control | grep -q bbr && echo "[+] BBR par défaut" || echo "[-] BBR non actif"

Sources:

https://github.com/virtio-win/virtio-win-pkg-scripts

https://computingforgeeks.com/how-to-enable-remote-desktop-protocol-rdp-on-windows-server-2019/

https://www.diskpart.com/windows-10/windows-10-mbr-to-gpt-0310.html

https://www.ubuntubuzz.com/2021/04/how-to-boot-uefi-on-qemu.html

https://github.com/tianocore/tianocore.github.io/wiki/OVMF-FAQ#what-is-open-virtual-machine-firmware-ovmf

https://plaza.quickbox.io/t/hetzner-server-setup-for-quickbox-raid-0/470

https://docs.hetzner.com/robot/dedicated-server/operating-systems/hetzner-aptitude-mirror

https://docs.hetzner.com/robot/dedicated-server/operating-systems/efi-system-partition

https://github.com/ArturiaPendragon/Linux-to-Windows-with-QEMU/blob/master/mediabots_Linux-to-Windows.sh

https://www.redhat.com/sysadmin/samba-windows-linux

https://christiansueur.com/samba-introduction-rapide-aux-partage-de-fichier-linux-windows/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment