macOS-Simple-KVM

在 QEMU 中快速设置 macOS 虚拟机的工具,由 KVM 加速。「Tools to set up a quick macOS VM in QEMU, accelerated by KVM.」

Github stars Tracking Chart

macOS-Simple-KVM

在 QEMU 中设置一个简单的、由 KVM 加速的 macOS 虚拟机的文档。

作者:@FoxletFox,并得到了许多其他作者的帮助。觉得这个有用吗?你可以在 on CoinbasePaypal! 上捐款!

你是 macOS 和 KVM 的新手?请查看常见问题

入门须知

你需要一个 Linux 系统,并使用 qemu (3.1 或更高版本)、python3、pip 和 KVM 模块。不需要 Mac 系统。以下是一些不同发行版的例子。

sudo apt-get install qemu-system qemu-utils python3 python3-pip  # for Ubuntu, Debian, Mint, and PopOS.
sudo pacman -S qemu python python-pip python-wheel  # for Arch.
sudo xbps-install -Su qemu python3 python3-pip   # for Void Linux.
sudo zypper in qemu-tools qemu-kvm qemu-x86 qemu-audio-pa python3-pip  # for openSUSE Tumbleweed
sudo dnf install qemu qemu-img python3 python3-pip # for Fedora
sudo emerge -a qemu python:3.4 pip # for Gentoo

第一步

运行 jumpstart.sh 下载 macOS 的安装介质(需要互联网)。默认安装使用 Catalina,但你可以通过添加 --high-sierra、--mojave 或 --catalina 来选择哪个版本。例如

./jumpstart.sh --mojave

注意:如果你已经下载了 BaseSystem.img,你可以跳过这个步骤。如果你有 BaseSystem.dmg,你将需要用 dmg2img 工具转换它。

第二步

使用 qemu-img 创建一个空硬盘,将名称和大小改为偏好。

qemu-img create -f qcow2 MyDisk.qcow2 64G

注意:如果你运行在无头系统上(如云提供商),你需要 -nographic 和 -vnc :0 -k en-us 来支持 VNC。

然后运行 basic.sh 来启动机器并安装 macOS。记得先在磁盘实用程序中进行分区!然后运行 basic.sh 启动机器并安装 macOS。

步骤 2a (虚拟机管理器)

如果不使用 QEMU,而是想将设置导入 Virt-Manager 中进行进一步的配置,只需运行 sudo ./make.sh --add。

运行上述命令后,在新添加的虚拟机条目的属性中添加 MyDisk.qcow2 为存储。

步骤 2b(无头系统)

如果你使用的是基于云的或者无头系统,你可以使用 headless.sh 来设置一个快速的 VNC 实例。设置通过变量来定义,如下例所示。默认情况下,VNC 将在 5900 端口启动。

HEADLESS=1 MEM=1G CPUS=2 SYSTEM_DISK=MyDisk.qcow2 ./headless.sh

第三步

你已经完成了!

要对系统进行微调并提高性能,请查看文档文件夹,以获取更多关于添加内存、设置桥接网络、添加直通硬件(针对GPU)、调整屏幕分辨率和启用声音功能的信息。


(The first version translated by vz on 2020.09.19)

Overview

Name With Ownerfoxlet/macOS-Simple-KVM
Primary LanguageShell
Program languageShell (Language Count: 2)
PlatformLinux
License:
Release Count0
Created At2019-04-22 07:25:20
Pushed At2024-04-04 15:48:46
Last Commit At2020-07-23 07:37:42
Stargazers Count13.5k
Watchers Count246
Fork Count1.1k
Commits Count74
Has Issues Enabled
Issues Count545
Issue Open Count327
Pull Requests Count19
Pull Requests Open Count38
Pull Requests Close Count26
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

macOS-Simple-KVM

Documentation to set up a simple macOS VM in QEMU, accelerated by KVM.

By @FoxletFox, and the help of many others. Find this useful? You can donate on Coinbase or Paypal!.

New to macOS and KVM? Check the FAQs.

Getting Started

You'll need a Linux system with qemu (3.1 or later), python3, pip and the KVM modules enabled. A Mac is not required. Some examples for different distributions:

sudo apt-get install qemu-system qemu-utils python3 python3-pip  # for Ubuntu, Debian, Mint, and PopOS.
sudo pacman -S qemu python python-pip            # for Arch.
sudo xbps-install -Su qemu python3 python3-pip   # for Void Linux.
sudo zypper in qemu-tools qemu-kvm qemu-x86 qemu-audio-pa python3-pip  # for openSUSE Tumbleweed

Step 1

Run jumpstart.sh to download installation media for macOS (internet required). The default installation uses Catalina, but you can choose which version to get by adding either --high-sierra, --mojave, or --catalina. For example:

./jumpstart.sh --mojave

Note: You can skip this if you already have BaseSystem.img downloaded. If you have BaseSystem.dmg, you will need to convert it with the dmg2img tool.

Step 2

Create an empty hard disk using qemu-img, changing the name and size to preference:

qemu-img create -f qcow2 MyDisk.qcow2 64G

and add it to the end of basic.sh:

    -drive id=SystemDisk,if=none,file=MyDisk.qcow2 \
    -device ide-hd,bus=sata.4,drive=SystemDisk \

Note: If you're running on a headless system (such as on Cloud providers), you will need -nographic and -vnc :0 -k en-us for VNC support.

Then run basic.sh to start the machine and install macOS. Remember to partition in Disk Utility first!

Step 2a (Virtual Machine Manager)

If instead of QEMU, you'd like to import the setup into Virt-Manager for further configuration, just run sudo ./make.sh --add.

Step 2b (Headless Systems)

If you're using a cloud-based/headless system, you can use headless.sh to set up a quick VNC instance. Settings are defined through variables as seen in the following example. VNC will start on port 5900 by default.

HEADLESS=1 MEM=1G CPUS=2 SYSTEM_DISK=MyDisk.qcow2 ./headless.sh

Step 3

You're done!

To fine-tune the system and improve performance, look in the docs folder for more information on adding memory, setting up bridged networking, adding passthrough hardware (for GPUs), and enabling sound features.

To the top