XNU Linux: Full OS X GUI Userspace on Linux
XNU Linux: Full OS X GUI Userspace on Linux
Run macOS userspace on Linux by loading the macOS kernel into it.
通过将 macOS 内核加载到 Linux 中,从而在 Linux 上运行 macOS 用户空间。
xnulinux builds XNU, the open-source kernel of macOS, from Apple’s published sources and runs it as a loadable kernel module (xnu.ko) inside an unmodified arm64 Linux kernel. The hosted XNU drives the CPU and MMU directly, so macOS processes run natively next to Linux processes on the same CPUs, with no hypervisor between them. Linux lends XNU its memory, timers, files, network and GPU through a small interface module (fki.ko).
xnulinux 从苹果发布的源代码构建 macOS 的开源内核 XNU,并将其作为可加载内核模块 (xnu.ko) 在未经修改的 arm64 Linux 内核中运行。托管的 XNU 直接驱动 CPU 和 MMU,因此 macOS 进程与 Linux 进程在同一 CPU 上原生运行,两者之间没有虚拟机管理程序。Linux 通过一个小型接口模块 (fki.ko) 将其内存、计时器、文件、网络和 GPU 提供给 XNU 使用。
With a stock Ubuntu kernel, insmod xnu.ko boots a macOS 27 system disk made by Apple’s own installer to the desktop: loginwindow, WindowServer, Dock, Finder, Safari and Chrome.
使用标准的 Ubuntu 内核,通过 insmod xnu.ko 可以引导由苹果官方安装程序制作的 macOS 27 系统磁盘进入桌面环境:包括 loginwindow、WindowServer、Dock、Finder、Safari 和 Chrome。
One system, two userspaces. Left: a Terminal in the hosted macOS 27.2.1 (sw_vers, the Darwin kernel, launchd, WindowServer, Dock and Finder running). Right: from that macOS, an SSH session into the Linux it runs inside (Ubuntu, Linux 7.0, the xnu and fki modules loaded, and the insmod xnu.ko process the macOS kernel runs in). Straight from the hosted framebuffer, 1280×800.
一套系统,两个用户空间。左侧:托管的 macOS 27.2.1 中的终端(运行着 sw_vers、Darwin 内核、launchd、WindowServer、Dock 和 Finder)。右侧:从该 macOS 发起的 SSH 会话,连接到其运行所在的 Linux 系统(Ubuntu,Linux 7.0,已加载 xnu 和 fki 模块,以及 macOS 内核运行所在的 insmod xnu.ko 进程)。直接来自托管帧缓冲区,分辨率为 1280×800。
The hosted desktop at the end of a 30-minute stress run, rendered on the CPU (no GPU bridge).
在 30 分钟压力测试结束时的托管桌面,由 CPU 渲染(无 GPU 桥接)。
Safari in the hosted macOS: Wikipedia’s article on XNU, kernel.org and the Linux repository on GitHub, over the hosted system’s network link through Linux, with the GPU bridge on (GPU=auto).
托管 macOS 中的 Safari:正在访问维基百科关于 XNU 的文章、kernel.org 以及 GitHub 上的 Linux 仓库,通过 Linux 的网络链路连接,并开启了 GPU 桥接(GPU=auto)。
Bare-metal NVIDIA DGX Spark (Ubuntu 24.04.5 LTS aarch64, Linux 7.0.0-1025-nvidia): hosted macOS 27 running with 4 CPUs and 8 GiB of RAM (CPU rendering), shown over macOS Screen Sharing alongside an SSH session from the DGX Spark host into the hosted Darwin userspace.
裸机 NVIDIA DGX Spark(Ubuntu 24.04.5 LTS aarch64, Linux 7.0.0-1025-nvidia):托管的 macOS 27 运行在 4 个 CPU 和 8 GiB 内存上(CPU 渲染),通过 macOS 屏幕共享显示,旁边是来自 DGX Spark 主机连接到托管 Darwin 用户空间的 SSH 会话。
Inside the hosted macOS on DGX Spark: About This Mac (Chip: Unknown, 7.80 GB memory, macOS Golden Gate 27.2) alongside sysctl machdep.cpu (ARM processor, hw.cpufamily: 0, hw.ncpu: 4) and hw.optional.arm.
在 DGX Spark 上托管的 macOS 内部:“关于本机”(芯片:未知,7.80 GB 内存,macOS Golden Gate 27.2),旁边是 sysctl machdep.cpu(ARM 处理器,hw.cpufamily: 0, hw.ncpu: 4)和 hw.optional.arm 的输出。
Working on two arm64 Linux setups:
目前可在两套 arm64 Linux 环境上运行:
What is still a stopgap is listed in docs/production.md. Notably: the OS cryptex is merged into the system volume, AMFI is patched and SIP relaxed, and memory access is slower than a native VM (4K pages vs 16K).
docs/production.md 中列出了目前仍作为权宜之计的部分。值得注意的是:OS cryptex 已合并到系统卷中,AMFI 已打补丁且 SIP 已放宽,内存访问速度比原生虚拟机慢(4K 页对比 16K 页)。
The Linux side and the XNU side are kept apart by license and meet only at FKI. Every source file carries an SPDX-License-Identifier; the license texts are in LICENSES/.
Linux 端和 XNU 端在许可协议上保持独立,仅在 FKI 处交汇。每个源文件都带有 SPDX-License-Identifier;许可协议文本位于 LICENSES/ 目录中。
xnu.ko is on the XNU side of the line: it runs XNU’s code in its own address space, so it is APSL-2.0 like XNU, and Linux reports it as a non-GPL module (MODULE_LICENSE(“Proprietary”), which taints the kernel as ZFS does). It must not include Linux headers beyond the module ABI, call Linux functions other than fki_*, or carry Linux code. Upstream code (XNU, macOS-DroidVM’s toolchain, Mesa, metal2vulkan, the Vulkan loader, LLVM) is fetched at pinned revisions and patched at build time; it is never committed.
xnu.ko 属于 XNU 端:它在自己的地址空间中运行 XNU 代码,因此与 XNU 一样采用 APSL-2.0 协议。Linux 将其报告为非 GPL 模块(MODULE_LICENSE(“Proprietary”),这会像 ZFS 一样污染内核)。它不得包含模块 ABI 之外的 Linux 头文件,不得调用 fki_* 以外的 Linux 函数,也不得携带 Linux 代码。上游代码(XNU、macOS-DroidVM 工具链、Mesa、metal2vulkan、Vulkan 加载器、LLVM)在构建时以固定版本获取并打补丁;它们从不被提交到仓库中。
macOS, Metal and XNU are trademarks of Apple Inc. This project is not affiliated with or endorsed by Apple.
macOS、Metal 和 XNU 是 Apple Inc. 的商标。本项目与苹果公司无关联,也未得到其认可。
Copyright © 2026 Heyang Zhou and contributors.
版权所有 © 2026 Heyang Zhou 及贡献者。
XNU as a loadable kernel module inside Linux (macOS personality for arm64 Linux)
作为 Linux 内部可加载内核模块的 XNU(用于 arm64 Linux 的 macOS 个性化环境)