單卡gpu直通,黑蘋果,amd_cpu教程
本文github地址:
Bebove/macos-kvm適用:
amd cpu(intel 也行?)
nvidia 顯卡,單卡。
安裝黑蘋果,(qemu虛擬機),通過pcie硬體直通,完成幾乎沒有性能損耗的黑蘋果虛擬機。
難點:
單卡,ubuntu宿主機器需要關閉xserver釋放顯卡佔用。需要主板支持iommu直通。
step1
- install ubuntu 18.04. It is important to use the same version of ubuntu.
- run install_qemu.sh. Which will install qemu4.0.0 for you.
- Install the vm, provided by //passthroughpo.st//:
cd ~
git clone https://github.com/Bebove/macOS-Simple-KVM
cd macOS-Simple-KVM
./jumpstart.sh #This will download High Sierra. Note that you can speed the download by replace the 1024 by a bigger number in macOS-Simple-KVM/tools/FetchMacOS/fetch-macos.py
qemu-img create -f qcow2 MyDisk.qcow2 64G
- adding these 2 lines to the basic.sh script
-drive id=SystemDisk,if=none,file=MyDisk.qcow2
-device ide-hd,bus=sata.4,drive=SystemDisk
step2
- run basic.sh,this scripe help you boot the vm.
- Install the macos to MyDisk normally. (You need to format MyDisk first)
- When you successfully boot into Macos, you should change the ScreenResolution in clover plist to your display resolution. You may need Clover Configurator to mount EFI,and modify the clover plist.
<key>ScreenResolution</key>
<string>1280x720</string>
- Also, please change the boot resolution:
Boot your VM, and press escape at the first UEFI dialog.
Type exit, hit enter. This should bring you to the OVMF configuration menu.
Navigate to Device Configuration > OVMF Platform Features
and set the resolution to the same value as your VM resolution.
If you did not change your VM resolution, set it to 1280×720.
Hit f10, Y, then press escape until you』re in the main dialog.
hit continue and boot into the VM. Shut it down fully
then Boot again to make sure the change didn』t cause any issues.
- now, if your vm is working normally, go to step3 to the virt-manager, which will help you add gpu passthrough.
step3
- Run those lines to install and enable virt-manager.
apt-get install virt-manager -y
systemctl enable libvirtd.service virtlogd.service
systemctl start libvirtd.service virtlogd.service
- Edit the /etc/libvirt/qemu.conf. you must uncomment these two lines:
user="root"
group="root"
- and run
systemctl restart libvirtd.service virtlogd.service
- Download the xml from this repo, edit all the paths in it to your own path!!
- Now you can change the cpu number of vm. Just change the two 8 in xml:
<vcpu placement=static>8</vcpu>
<cpu>
<topology sockets=1 cores=8 threads=1/>
</cpu>
- Run
virsh define macos.xml
virt-manager
- Then you can see a gui vm manager. run the macos, it should work fine.
- Install the nvidia driver within the osx vm. You need to download and install nvidia web driver for your osx verson. Then reboot and shut down.
step4
- In virt-manager ,you should delete the old mouse/keyboard.
- Add new mouth/keyboard, which can be added by click add hardware --> usb host device
- use
lspci -nn |grep NVIDIA
to get the iommu_id of nvidiacard.
- Download grub in this repo.
- Delete the /etc/default/grub, and put the grup downloaded in there. Change the:
vfio-pci.ids=10de:1b81,10de:10f0
- 「10de:1b81,10de:10f0「 in file grup to the iommu_id found by
lspci -nn |grep NVIDIA
- then reboot your computer.
- Go into virt-manager, add nvidia card via virt-manager. add hardware --> PCI host device . There are two to add. which may seem like: