KVM Hackintosh

概览:

参考 :

https://www.bilibili.com/video/av49951276

安装

1
2
3
4
5
6
7
sudo apt install qemu
sudo apt install libvirt
sudo apt install virt-manager

sudo apt install iptables ebtables dnsmasq
sudo systemctl restart libvirtd
sudo virsh net-start default

启动virt服务

1
2
sudo systemctl enable libvirt
sudo systemctl start libvirt

有报错请安装gir1.2-spiceclientgtk-3.0

1
sudo apt install gir1.2-spiceclientgtk-3.0

目录结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
MyMac
├── Example-OSX-Virt-Manager
│ ├── example-config.plist
│ ├── iommu.sh
│ ├── OSX.xml
│ └── README.md
├── MacKVM.sh
├── macOS-Simple-KVM
│ ├── BaseSystem.img
│ ├── basic.sh
│ ├── docs
│ │ ├── FAQs.md
│ │ ├── guide-networking.md
│ │ ├── guide-passthrough.md
│ │ ├── guide-performance.md
│ │ └── guide-screen-resolution.md
│ ├── ESP.qcow2
│ ├── firmware
│ │ ├── LICENSE
│ │ ├── OVMF_CODE.fd
│ │ └── OVMF_VARS-1024x768.fd
│ ├── headless.sh
│ ├── jumpstart.sh
│ ├── make.sh
│ ├── README.md
│ ├── tools
│ │ ├── debug.sh
│ │ ├── dmg2img
│ │ ├── dmg2img-src
│ │ ├── FetchMacOS
│ │ │ ├── BaseSystem
│ │ │ │ ├── BaseSystem.chunklist
│ │ │ │ └── BaseSystem.dmg
│ │ │ ├── fetch-macos.py
│ │ │ ├── fetch.sh
│ │ │ └── requirements.txt
│ │ └── template.xml.in
│ └── virtio.sh
└── MyDisk.qcow2

8 directories, 30 files

先验步骤

1
2
3
4
git clone https://github.com/foxlet/macOS-Simple-KVM.git
git clone https://github.com/PassthroughPOST/Example-OSX-Virt-Manager.git
cd macOS-Simple-KVM
./jumpstart.sh

执行脚本MacKVM.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash --posix

OSK="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VMDIR=/home/mardan/Desktop/vmware/MyMac #路径位置,根据自己的实际设置
OVMF=$VMDIR/macOS-Simple-KVM #路径位置,根据自己的实际设置


qemu-system-x86_64 \
-enable-kvm \
-m 8G \
-machine q35,accel=kvm \
-smp 4,cores=2 \
-cpu Penryn,vendor=GenuineIntel,kvm=on,+sse3,+sse4.2,+aes,+xsave,+avx,+xsaveopt,+xsavec,+xgetbv1,+avx2,+bmi2,+smep,+bmi1,+fma,+movbe,+invtsc \
-device isa-applesmc,osk="$OSK" \
-smbios type=2 \
-drive if=pflash,format=raw,readonly,file="$OVMF/firmware/OVMF_CODE.fd" \
-drive if=pflash,format=raw,file="$OVMF/firmware/OVMF_VARS-1024x768.fd" \
-vga qxl \
-device ich9-intel-hda -device hda-output \
-usb -device usb-kbd -device usb-mouse \
-netdev user,id=net0 \
-device e1000-82545em,netdev=net0,id=net0,mac=59:b8:e6:66:7b:ec \
-device ich9-ahci,id=sata \
-drive id=ESP,if=none,format=qcow2,file=$OVMF/ESP.qcow2 \
-device ide-hd,bus=sata.2,drive=ESP \
-drive id=InstallMedia,format=raw,if=none,file=$OVMF/BaseSystem.img \
-device ide-hd,bus=sata.3,drive=InstallMedia \
-drive id=SystemDisk,if=none,file=$VMDIR/MyDisk.qcow2 \
-device ide-hd,bus=sata.4,drive=SystemDisk \

启动

1
sudo ./MacKVM.sh