ohetfi

start-windows-10-pro.sh

Sep 15th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.22 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # QEMU name and PID
  4. VM_NAME="windows-10-pro"
  5. OPTS="-name $VM_NAME"
  6. OPTS="$OPTS -pidfile /tmp/$VM_NAME.pid"
  7.  
  8. # Processor
  9. OPTS="$OPTS -cpu host,kvm=off"
  10. OPTS="$OPTS -smp 8,sockets=1,cores=4,threads=2"
  11. OPTS="$OPTS -enable-kvm"
  12.  
  13. # Machine
  14. #OPTS="$OPTS -machine type=pc-i440fx-2.1,accel=kvm"
  15. OPTS="$OPTS -machine type=pc-i440fx-2.4,accel=kvm"
  16. #OPTS="$OPTS -machine type=q35,accel=kvm"
  17.  
  18. # The following setting enables S3 (suspend to RAM). OVMF supports S3
  19. # suspend/resume. Disable when using Q35
  20. OPTS="$OPTS -global PIIX4_PM.disable_s3=0"
  21.  
  22. # Memory
  23. OPTS="$OPTS -m 16G"
  24. OPTS="$OPTS -mem-path /dev/hugepages"
  25. OPTS="$OPTS -mem-prealloc"
  26. OPTS="$OPTS -balloon none"
  27.  
  28. # Hardware clock
  29. OPTS="$OPTS -rtc clock=host,base=utc"
  30.  
  31. # Sound hardware
  32. #QEMU_PA_SAMPLES=128
  33. #export QEMU_AUDIO_DRV=pa
  34. #OPTS="$OPTS -soundhw hda"
  35. export QEMU_AUDIO_DRV=alsa
  36. OPTS="$OPTS -soundhw ac97"
  37.  
  38. # Graphic card passthrough (Gigabyte GeForce GTX 980 G1 Gaming)
  39. OPTS="$OPTS -device vfio-pci,host=01:00.0,multifunction=on"
  40. OPTS="$OPTS -device vfio-pci,host=01:00.1"
  41.  
  42. # USB 3.0 passthrough (NEC/Renesas)
  43. OPTS="$OPTS -device vfio-pci,host=03:00.0"
  44.  
  45. # USB 2.0 passthrough (NEC)
  46. OPTS="$OPTS -device vfio-pci,host=0a:01.0"
  47.  
  48. # Keyboard layout
  49. OPTS="$OPTS -k en-us"
  50.  
  51. # Boot priority
  52. OPTS="$OPTS -boot order=c"
  53.  
  54. # OVMF
  55. OPTS="$OPTS -drive if=pflash,format=raw,readonly,file=/data/machines/$VM_NAME/ovmf/OVMF_CODE-pure-efi.fd"
  56. OPTS="$OPTS -drive if=pflash,format=raw,file=/data/machines/$VM_NAME/ovmf/OVMF_VARS-pure-efi.fd"
  57.  
  58. # System drive
  59. OPTS="$OPTS -drive id=disk0,if=none,cache=unsafe,format=raw,file=/data/machines/$VM_NAME/disks/disk0-system.img"
  60. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi0"
  61. OPTS="$OPTS -device scsi-hd,drive=disk0"
  62.  
  63. # 1st Game drive
  64. OPTS="$OPTS -drive id=disk1,if=none,cache=none,aio=native,format=raw,file=/dev/disk/by-id/ata-Hitachi_HDS721050CLA660_JP1570FR1ZWP7K"
  65. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi1"
  66. OPTS="$OPTS -device scsi-hd,drive=disk1"
  67.  
  68. # 2nd Game drive
  69. OPTS="$OPTS -drive id=disk2,if=none,cache=none,aio=native,format=raw,file=/dev/disk/by-id/ata-Hitachi_HDS5C3020ALA632_ML0220F30NX2DD"
  70. OPTS="$OPTS -device driver=virtio-scsi-pci,id=scsi2"
  71. OPTS="$OPTS -device scsi-hd,drive=disk2"
  72.  
  73. # Windows 10 Pro installer
  74. #OPTS="$OPTS -drive id=cd0,if=none,format=raw,readonly,file=/data/machines/$VM_NAME/iso/Windows_10_Professional_64_Bit.iso"
  75. #OPTS="$OPTS -device driver=ide-cd,bus=ide.0,drive=cd0"
  76.  
  77. # Virtio driver
  78. #OPTS="$OPTS -drive id=virtiocd,if=none,format=raw,file=/data/iso/VirtIO/virtio-win-0.1.109.iso"
  79. #OPTS="$OPTS -device driver=ide-cd,bus=ide.1,drive=virtiocd"
  80.  
  81. # OVMF emits a number of info / debug messages to the QEMU debug console, at
  82. # ioport 0x402. We configure qemu so that the debug console is indeed
  83. # available at that ioport. We redirect the host side of the debug console to
  84. # a file.
  85. OPTS="$OPTS -global isa-debugcon.iobase=0x402 -debugcon file:/tmp/$VM_NAME.ovmf.log"
  86.  
  87. # QEMU accepts various commands and queries from the user on the monitor
  88. # interface. Connect the monitor with the qemu process's standard input and
  89. # output.
  90. #OPTS="$OPTS -monitor stdio"
  91. #OPTS="$OPTS -vga qxl"
  92.  
  93. # A USB tablet device in the guest allows for accurate pointer tracking
  94. # between the host and the guest.
  95. OPTS="$OPTS -device piix3-usb-uhci -device usb-tablet"
  96.  
  97. # Network
  98. OPTS="$OPTS -netdev tap,vhost=on,ifname=$VM,id=brlan"
  99. OPTS="$OPTS -device virtio-net-pci,mac=$(/usr/local/bin/qemu-mac-hasher $VM_NAME),netdev=brlan"
  100.  
  101. # Disable display
  102. OPTS="$OPTS -vga none"
  103. OPTS="$OPTS -serial null"
  104. OPTS="$OPTS -parallel null"
  105. OPTS="$OPTS -monitor none"
  106. OPTS="$OPTS -display none"
  107. #OPTS="$OPTS -daemonize"
  108.  
  109. # QEMU Guest Agent
  110. OPTS="$OPTS -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0"
  111. OPTS="$OPTS -device virtio-serial"
  112. OPTS="$OPTS -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"
  113.  
  114. sudo echo "Starting $VM_NAME machine"
  115.  
  116. # Disable Dell U2312HM display
  117. xrandr --output HDMI1 --off --output HDMI3 --mode 1920x1080 --pos 0x0 --rotate normal
  118.  
  119. # Start Windows 10 Pro
  120. sudo taskset -c 0-7 qemu-system-x86_64 $OPTS
  121.  
  122. # Restore Dell U2312HM display
  123. xrandr --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI3 --mode 1920x1080 --pos 1920x0 --rotate normal
Advertisement
Add Comment
Please, Sign In to add comment