要求:
系統(tǒng): ubuntu 20
硬件:兩塊顯卡跟压,一塊用于顯卡直通
bios: bios開(kāi)啟虛擬配置
一吓懈、環(huán)境準(zhǔn)備:
1麻养、 安裝 ubuntu 20 操作系統(tǒng)
2举塔、更換阿里源:
vim /etc/apt/sources.list
如果缺少vim 命令,使用如下命令安裝
sudo apt install vim
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
3猜丹、安裝kvm所需軟件:
sudo apt update
sudo apt -y install qemu-kvm libvirt-daemon qemu-system qemu-utils python3 python3-pip bridge-utils virtinst libvirt-daemon-system virt-manager
4芝加、確保已加載并啟用vhost_net模塊:
$ sudo modprobe vhost_net
$ lsmod | grep vhost
$ echo vhost_net | sudo tee -a /etc/modules
5、啟動(dòng)kvm:
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
二射窒、下載macOS的安裝媒體:
1藏杖、下載git項(xiàng)目
sudo apt -y install git
然后在github上克隆項(xiàng)目代碼。
git clone https://github.com/foxlet/macOS-Simple-KVM.git
cd macOS-Simple-KVM
2脉顿、運(yùn)行安裝程序腳本以下載macOS的安裝介質(zhì)(需要互聯(lián)網(wǎng)):
./jumpstart.sh --catalina #默認(rèn)安裝使用Catalina蝌麸,但您可以通過(guò)添加–high-sierra,–mojave或–catalina選擇要獲得的版本
3艾疟、啟動(dòng)安裝macOS:
我們需要使用qemu-img為macOS系統(tǒng)創(chuàng)建一個(gè)空硬盤(pán):
$ qemu-img create -f qcow2 macOS.qcow2 50G
修改basic.sh文件来吩,并在下面添加以下行:
-drive id=SystemDisk,if=none,file=macOS.qcow2 \
-device ide-hd,bus=sata.4,drive=SystemDisk \
現(xiàn)在,我們可以運(yùn)行命令:
./basic.sh #進(jìn)行安裝mac系統(tǒng)
三蔽莱、 將設(shè)置導(dǎo)入到Virt-Manager
sudo ./make.sh --add
運(yùn)行上述命令后弟疆,在新添加的VM條目的屬性中將macOS.qcow2添加為存儲(chǔ)
參考資料
https://note.youdao.com/ynoteshare1/index.html?id=a56e1f9cc7f47d23e275fdc6afab76b9&type=note
https://ywnz.com/linuxaz/6752.html