Advertisement
Guest User

Windows 11 on Asahi Linux (QEMU)

a guest
Mar 23rd, 2025
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.77 KB | Software | 0 0
  1. # References:
  2. #  - Davide Cavalca from the Asahi team on Matrix
  3. #  - https://gist.github.com/Vogtinator/293c4f90c5e92838f7e72610725905fd
  4. #  - https://www.tomshardware.com/how-to/bypass-windows-11-tpm-requirement
  5. #  - https://www.tomshardware.com/how-to/install-windows-11-without-microsoft-account
  6. #  - https://github.com/virtio-win/kvm-guest-drivers-windows/wiki/Driver-installation
  7.  
  8. # Download prerequisites
  9. # - virtio-win.iso
  10. #   - From: https://github.com/virtio-win/kvm-guest-drivers-windows/wiki/Driver-installation
  11. # - Win11_24H2_English_Arm64.iso
  12. #   - From: https://www.microsoft.com/en-us/software-download/windows11arm64
  13.  
  14. # Install prerequisites
  15. sudo dnf5 install qemu-system-aarch64 qemu-img
  16.  
  17. # Create a disk image
  18. qemu-img create -f qcow2 win11.qcow2 64G
  19.  
  20. # Install Windows
  21. performance_cores=$(awk '
  22.  /^processor/ { proc=$3 }
  23.  /^CPU part/ {
  24.    if ($4 == "0x023" || $4 == "0x025" || $4 == "0x029" || $4 == "0x033" || $4 == "0x035" || $4 == "0x039")
  25.      procs=procs ? procs","proc : proc
  26.  } END { print procs }
  27. ' /proc/cpuinfo)
  28.  
  29. taskset -c "$performance_cores" \
  30.   qemu-system-aarch64 \
  31.     -M virt \
  32.     -cpu host \
  33.     -accel kvm \
  34.     -m 10G \
  35.     -smp $(nproc) \
  36.     -device ramfb \
  37.     -bios /usr/share/edk2/aarch64/QEMU_EFI.fd \
  38.     -device qemu-xhci \
  39.     -device usb-kbd \
  40.     -device usb-tablet \
  41.     -drive file=Win11_24H2_English_Arm64.iso,media=cdrom,if=none,id=inst \
  42.     -device usb-storage,drive=inst \
  43.     -drive file=virtio-win-0.1.266.iso,media=cdrom,if=none,id=iso \
  44.     -device usb-storage,drive=iso \
  45.     -drive file=win11.qcow2,if=virtio \
  46.     -nic user,model=virtio-net-pci,mac=2A:50:A7:4E:D9:C4
  47.  
  48. ## Bypass TPM:
  49. #  - During first installation screen, press Shift+Fn+F10
  50. #  - Type regedit
  51. #  - Navigate to HKEY_LOCAL_MACHINE\SYSTEM\Setup
  52. #  - Create a new Key; name it LabConfig
  53. #  - Under LabConfig, create two DWORD values BypassTPMCheck and BypassSecureBootCheck and BypassRAMCheck, and set each to 1
  54. #  - Close regedit and cmd and continue the installation as normal
  55.  
  56. ## Installation process:
  57. #  - When asked for a product key, click on "I don't have a product key"
  58. #  - Select any version, for example Pro
  59. #  - At disk selection screen, click on Load Driver, Browse, then navigate to E:\viostor\w11\ARM64, then install that driver
  60. #  - Then create a partition and choose partition 3
  61. #  - Installation might get stuck at 42% or such for 30mins or so.. it's not stuck
  62. #  - The VM may reboot a couple of times before installation completes.
  63. #  - Complete the installation until it asks for network, click Install Driver then install NetKVM by going to E:\NetKVM\w11\ARM64
  64. #  - The VM may reboot a couple of more times and installs updates.
  65. #  - Next, install the virtio drivers
  66. #  - Reboot and now can use the command below to boot the VM
  67.  
  68. ## Skipping account creation during setup
  69. #  - Once installation gets to the point where it requires an account
  70. #  - Press Shift+Fn+F10 and type oobe\bypassnro and press Enter. The machine will reboot
  71. #  - After the reboot, press Shift+Fn+F10 again and type ipconfig /release and hit enter, then continue the installation
  72. #  - When asked about connecting to a network, click "I don't have Internet"
  73. #  - Once we make it to Desktop, the next step is to install the guest tools. Navigate to E:\ and click on "virtio-win-guest-tools.exe"
  74. #  - Use the installer to install all the drivers.
  75. #  - At this point, the VM is ready to switch to the virtio drivers. Shutdown the VM.
  76. #  - From this point on, you can use the following command to start the VM:
  77.  
  78. performance_cores=$(awk '
  79.  /^processor/ { proc=$3 }
  80.  /^CPU part/ {
  81.    if ($4 == "0x023" || $4 == "0x025" || $4 == "0x029" || $4 == "0x033" || $4 == "0x035" || $4 == "0x039")
  82.      procs=procs ? procs","proc : proc
  83.  } END { print procs }
  84. ' /proc/cpuinfo)
  85.  
  86. taskset -c "$performance_cores" \
  87.   qemu-system-aarch64 \
  88.     -M virt \
  89.     -cpu host \
  90.     -accel kvm \
  91.     -m 10G \
  92.     -smp $(nproc) \
  93.     -bios /usr/share/edk2/aarch64/QEMU_EFI.fd \
  94.     -device qemu-xhci \
  95.     -device usb-kbd \
  96.     -device usb-tablet \
  97.     -drive file=win11.qcow2,if=virtio \
  98.     -nic user,model=virtio-net-pci \
  99.     -object rng-random,filename=/dev/urandom,id=rng0 \
  100.     -device virtio-rng-pci,rng=rng0 \
  101.     -audio driver=pipewire,model=virtio \
  102.     -device virtio-gpu-pci \
  103.     -display sdl,gl=on \
  104.     -device usb-kbd \
  105.     -device usb-tablet
  106.  
  107. ## Post installation notes:
  108. #  - Maximize the QEMU window to get higher display resolution.
  109. #  - Note that the first boot will take a while without a display. Just showing "Display output is not active". This is normal and goes away once the VM fully boots after a few mins.
  110. #  - Feel free to attach more devices or pass peripherals through by adjusting the command line above. Check QEMU docs/forums for more details.
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement