Advertisement
Guest User

boot-passthrough

a guest
Mar 3rd, 2022
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Special thanks to:
  4. # https://github.com/Leoyzen/KVM-Opencore
  5. # https://github.com/thenickdude/KVM-Opencore/
  6. # https://github.com/qemu/qemu/blob/master/docs/usb2.txt
  7. #
  8. # qemu-img create -f qcow2 mac_hdd_ng.img 128G
  9. #
  10. # echo 1 > /sys/module/kvm/parameters/ignore_msrs (this is required)
  11.  
  12. ############################################################################
  13. # NOTE: Tweak the "MY_OPTIONS" line in case you are having booting problems!
  14. ############################################################################
  15.  
  16. MY_OPTIONS="+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check"
  17.  
  18. # This script works for Big Sur, Catalina, Mojave, and High Sierra. Tested with
  19. # macOS 10.15.6, macOS 10.14.6, and macOS 10.13.6
  20.  
  21. ALLOCATED_RAM="3072" # MiB
  22. CPU_SOCKETS="1"
  23. CPU_CORES="2"
  24. CPU_THREADS="4"
  25.  
  26. REPO_PATH="."
  27. OVMF_DIR="."
  28.  
  29. # Note: This script assumes that you are doing CPU + GPU passthrough. This
  30. # script will need to be modified for your specific needs!
  31. #
  32. # We recommend doing the initial macOS installation without using passthrough
  33. # stuff. In other words, don't use this script for the initial macOS
  34. # installation.
  35.  
  36. # shellcheck disable=SC2054
  37. args=(
  38. -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off
  39. -enable-kvm -m "$ALLOCATED_RAM" -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,"$MY_OPTIONS"
  40. -machine q35
  41. -usb -device usb-kbd -device usb-tablet -device usb-host,hostbus=1,hostaddr=18
  42. -smp "$CPU_THREADS",cores="$CPU_CORES",sockets="$CPU_SOCKETS"
  43. -device usb-ehci,id=ehci
  44. -vga none
  45. -device vfio-pci,host=03:00.0,multifunction=on,romfile="/var/lib/libvirt/vbios/Sapphire.RX550.4096.170918.rom"
  46. -device vfio-pci,host=03:00.1
  47. -device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
  48. -drive if=pflash,format=raw,readonly=on,file="$REPO_PATH/$OVMF_DIR/OVMF_CODE.fd"
  49. -drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS-1024x768.fd"
  50. -smbios type=2
  51. -device ich9-intel-hda -device hda-duplex
  52. -device ich9-ahci,id=sata
  53. -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2"
  54. -device ide-hd,bus=sata.2,drive=OpenCoreBoot
  55. -device ide-hd,bus=sata.3,drive=InstallMedia
  56. -drive id=InstallMedia,if=none,file="$REPO_PATH/BaseSystem.img",format=raw
  57. -drive id=MacHDD,if=none,file="$REPO_PATH/mac_hdd_ng.img",format=qcow2
  58. -device ide-hd,bus=sata.4,drive=MacHDD7
  59. -netdev user,id=net0 -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:c9:18:27
  60. #-monitor stdio
  61. -display none
  62. )
  63.  
  64. qemu-system-x86_64 "${args[@]}"
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement