Featured image of post XNU Linux: the macOS kernel running as a module inside Linux

XNU Linux: the macOS kernel running as a module inside Linux

An open source project loads XNU, the macOS kernel, as an arm64 Linux module and boots the macOS 27 desktop with no hypervisor.

Picture typing a single command on Linux, an insmod, and watching the macOS login screen show up. No virtual machine in between. Apple’s kernel loaded like any other driver, sharing the same CPU with Linux. That’s what a project published on GitHub on November 20, 2026 is showing. And it made it all the way to Finder, the Dock and Safari.

Two terminals side by side: on the left macOS 27.2.1 with the Darwin kernel, on the right Ubuntu with the xnu and fki modules loaded Image: xnulinux project (Heyang Zhou and contributors) — source

First, what is this XNU thing

Every operating system has a kernel, the part that talks straight to the hardware: memory, processor, disk, network. On Linux, the kernel is Linux itself. On macOS, it’s called XNU, short for “X is Not Unix”.

XNU was born at NeXT, for the NeXTSTEP system, and Apple has been developing it since December 1996. It’s a hybrid kernel. It combines Mach, a microkernel created at Carnegie Mellon University, with a good chunk of BSD code. The detail that matters today is that Apple publishes XNU’s source code as open source, under the APSL license. In other words, anyone can download it and compile it.

But compiling the kernel is one thing. Getting it to run, bring up the whole macOS graphical interface and open apps is a very different thing.

What the xnulinux project pulled off

The repository is called xnulinux and lives under the AFK-surf account. The footer credits Heyang Zhou and contributors. According to the GitHub API, it was created on November 20, 2026. Three days later, it already had almost 2,000 stars and nearly 600 points on Hacker News.

The pitch, in the README’s words, is to run macOS userspace on Linux by loading the macOS kernel into it. XNU is built from the code Apple publishes and becomes a loadable module, xnu.ko. That module goes into an arm64 Linux kernel with no modifications at all. The author says that with the stock Ubuntu kernel, insmod xnu.ko boots a macOS 27 system disk to the desktop, with loginwindow, WindowServer, Dock, Finder, Safari and Chrome.

He tested two setups. The first is an Apple Silicon Mac running an arm64 Linux virtual machine. There, according to the project, macOS 27.2.1 reaches the desktop in 31 to 48 seconds. A regular macOS VM on the same Mac took 49. The author also reports a 30-minute stress test, with 40 rounds of opening Safari, Notes, Calculator and System Settings, without a single kernel panic.

The second setup is the eye-catching one: an NVIDIA DGX Spark, with no virtualization at all, running Ubuntu directly on the machine. macOS boots with 4 cores and 8 GB of RAM reserved for XNU. There, for now, the screen is drawn by the CPU, because the GPU bridge only works with a virtual GPU.

The hosted macOS terminal showing processor details and the About This Mac window with the name xnulinux and 7.80 GB of memory Image: xnulinux project (Heyang Zhou and contributors) — source

An honest caveat: all of these numbers come from the repository itself. Phoronix also covered the project, but so far I haven’t seen anyone independent reproducing the tests.

How two kernels share the same machine

This is the part I find most interesting. Normally, to run one system inside another, you use a hypervisor, the software that creates virtual machines. xnulinux doesn’t. XNU drives the CPU and the MMU, the unit that translates memory addresses, directly.

The trick lives in a second module, fki.ko. The name stands for “foreign kernel interface”. It’s what lends XNU the things that belong to Linux: memory, timers, files, network and GPU.

In practice, it works like this. Each CPU macOS sees is actually a Linux kernel thread pinned to a physical core. XNU runs on that thread until it needs something from the host, like waiting on a timer or doing I/O. Then it hands control back. When a page fault or an exception happens in XNU code, fki.ko forwards it to XNU’s own handler.

Memory is one contiguous block that Linux sets aside right at the start, and XNU manages that block its own way. The macOS disk is a file on the Linux side. The network is a Linux network interface. Even Metal, Apple’s graphics API, gets translated to Vulkan and reaches the host GPU through a bridge.

Layered diagram of XNU: user mode on top; in kernel mode, the BSD layer with file systems and networking and, below it, Mach with virtual memory, IPC and scheduling Image: Robryecran77 / Wikimedia Commons, CC BY-SA 4.0 — source

Then there are the licenses, which are both a technical and a legal piece. fki.ko is GPL 2.0, the Linux license. xnu.ko and the XNU patches stay under the APSL, Apple’s license. That split is on purpose. The idea of wrapping XNU in a Linux module isn’t even new: Darling, a compatibility layer that runs macOS programs on Linux, already does something similar, but there the module mostly handles communication between processes. xnulinux goes much further and boots the whole system.

Why this matters even if you’ll never run macOS on Linux

To start with, the project doesn’t ship anything from Apple. According to the README, you need your own macOS 27 installation, made with the official installer, and a Mac with Xcode to build the disk. You also need an arm64 Linux machine with at least 16 GB of RAM. So this isn’t something for your x86 PC today.

What matters for developers and infrastructure folks is what it shows. A kernel doesn’t have to be the absolute owner of the machine. With a well-designed interface, you can put two kernels from different families side by side, each with its own processes. Today this looks like a lab experiment. But I’d bet ideas like this resurface down the road in lightweight virtualization and in testing tools.

Safari running on the hosted macOS, open on kernel.org with the list of Linux kernel releases Image: xnulinux project (Heyang Zhou and contributors) — source

My take

It’s impressive, but it’s a proof of concept, and the author makes that clear. In the docs, he lists what is still a stopgap. The macOS system partition loses its integrity seal. AMFI, the mechanism that checks code signatures, gets patched. SIP, System Integrity Protection, is relaxed. Kernel address randomization is turned off. And code that leans heavily on memory can be up to 1.6 times slower.

My reading is that today it’s for learning, not for production. There’s also a question the README doesn’t answer: whether running macOS this way, especially on hardware that isn’t Apple’s, like the DGX Spark, complies with the macOS license. I’m not a lawyer. But before using this at a company, I’d ask that question.

What now?

If you have an Apple Silicon Mac and like tinkering with operating systems, the README is the place to go. It has the build scripts step by step and a page just for the current limitations. If you don’t, it’s still worth reading the section that explains how the project works. You rarely get to see, in a short text, how two kernels manage to live together.

A kernel Apple built for Macs booting as a module inside Linux, three days into a public project. What would you use this for? Tell me in the comments.

Sources

Built with Hugo
Theme Stack designed by Jimmy