ubuntu 20 安装kvm + mac os

要求:

系统: ubuntu 20

硬件:两块显卡,一块用于显卡直通

bios: bios开启虚拟配置

一、环境准备:

1、 安装 ubuntu 20 操作系统

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、启动kvm:

sudo systemctl start libvirtd

sudo systemctl enable libvirtd

二、下载macOS的安装媒体:

1、下载git项目

sudo apt -y install git

然后在github上克隆项目代码。

git clone https://github.com/foxlet/macOS-Simple-KVM.git

cd macOS-Simple-KVM

2、运行安装程序脚本以下载macOS的安装介质(需要互联网):

./jumpstart.sh --catalina #默认安装使用Catalina,但您可以通过添加–high-sierra,–mojave或–catalina选择要获得的版本

3、启动安装macOS:

我们需要使用qemu-img为macOS系统创建一个空硬盘:

$ 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 \

现在,我们可以运行命令:

./basic.sh #进行安装mac系统

三、 将设置导入到Virt-Manager

sudo ./make.sh --add

运行上述命令后,在新添加的VM条目的属性中将macOS.qcow2添加为存储

参考资料
https://note.youdao.com/ynoteshare1/index.html?id=a56e1f9cc7f47d23e275fdc6afab76b9&type=note
https://ywnz.com/linuxaz/6752.html

你可能感兴趣的:(ubuntu 20 安装kvm + mac os)