简单记录在服务器 Docker 上使用 Qemu 安装 Win11


You’ll need CPU host passthrough enabled (check /proc/cpuinfo for details).

Assuming QEMU and related packages are already installed, I won’t repeat those steps here.

{/* truncate */}

Preparation

Download the Windows 11 ISO:

Download Windows 11

Download the Virtio Windows driver ISO:

https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/

Installation

Create a qcow2 Disk

Terminal window
qemu-img create -f qcow2 windows11.qcow2 120G

Start QEMU

Create a shell script (e.g., run-win11.sh):

#!/bin/sh
qemu-system-x86_64 \
-enable-kvm \
-smp 12,cores=6,threads=2 \
-m 12G \
-machine usb=on \
-device usb-tablet \
-cpu host \
-vga virtio \
-device e1000,netdev=net0 \
-netdev user,id=net0,net=192.168.20.0/24,dhcpstart=192.168.20.20 \
-drive file=windows11.qcow2,if=virtio \
-drive file=virtio-win-0.1.262.iso,index=1,media=cdrom \
-drive file=Windows.iso,index=2,media=cdrom \
-vnc :1
  • Windows.iso is the Windows 11 installation ISO.
  • windows11.qcow2 is the VM disk you created.
  • virtio-win-*.iso is the Virtio driver ISO.

This command opens VNC on display :1 (port 5901). I forwarded it over SSH:

Terminal window
ssh -L 5901:localhost:5901 root@<host> -p <port>

Connect via VNC

On my Arch host, I used TigerVNC:

Terminal window
vncviewer localhost:5901

You should now see the Windows installer.

Next, bypass the TPM/Secure Boot/RAM checks:

  1. In the installer, press Shift+F10 to open a Command Prompt.
  2. Run regedit to open the Registry Editor.
  3. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\Setup.
  4. Create a new key named LabConfig.
  5. Under LabConfig, create three DWORD (32-bit) values and set them to 1:
    • BypassTPMCheck
    • BypassSecureBootCheck
    • BypassRAMCheck

Registry Editor

Continue the installer until you reach the disk selection screen. Click Load Driver, browse to the Virtio driver, and choose the correct architecture.

Load Virtio Driver

After loading the driver, your Virtio disk appears. Proceed with the installation as usual.

References

{/* AI */}

Table of Contents