You Can Now Run macOS Userspace on Linux by Loading XNU as a Kernel Module
You've probably seen macOS-in-a-VM projects before—QEMU, UTM, Docker-OSX, and the like. But what if you skipped the hypervisor entirely and loaded Apple's actual kernel into your Linux box as a module? That's the premise behind xnulinux, and it's a much stranger and more interesting idea than it first sounds.
What It Does
xnulinux builds XNU—the open-source kernel at the heart 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 alongside Linux processes on the same CPUs, with no hypervisor sitting between them.
Linux lends XNU its memory, timers, files, network, and GPU through a small companion module called fki.ko (the foreign kernel interface). With a stock Ubuntu kernel, insmod xnu.ko boots a macOS 27 system disk made by Apple's own installer all the way to the desktop—loginwindow, WindowServer, Dock, Finder, Safari, and Chrome. The diagram in the README lays it out: your macOS processes sit on top of source-built XNU, which talks to xnu.ko, which talks to fki.ko, which talks to the Linux kernel underneath.
Why It's Cool
-
No hypervisor means no virtualization tax. XNU runs on the real CPU, managing memory with its own pmap. Linux keeps its own exception vectors, and
fki.koforwards faults and user exceptions from XNU code back to XNU's handlers. It's cooperative multitasking between two kernels, not one kernel pretending to be a machine. -
The hardware handoff is genuinely clever. Each hosted CPU is a Linux kernel thread pinned to a real Linux CPU. XNU runs on it until it needs the host—for idle, I/O, or a timer—and then hands control back. XNU gets one physically contiguous block of memory from Linux via CMA, and the two kernels share the user half of the address space layout with 4K pages.
-
Devices are just kexts. The project ships a
kexts/directory that gives macOS a disk (backed by a file on the Linux side), a display (a framebuffer Linux reads), a keyboard and pointer, an Ethernet link (a Linux network interface), a keystore, and a GPU bridge. That's a clean way to think about hardware when your "hardware" is really another operating system. -
Metal works, sort of. Metal in the hosted macOS runs on
gpu/xnu-cpu-metal(metal2vulkan over Vulkan). Vulkan reaches the host GPU through a DRM bridge (kexts/XnuDrm→ host call →gpu/xnu-drm/xnudrmd→ the Linux render node), using Mesa's Venus driver. Without a supported DRM backend, it falls back to Mesa lavapipe on the CPU. The README is honest that CPU rendering is a real fallback, not a theoretical one. -
It runs on stock kernels. Not a patched, custom-built Linux—a distro kernel. The README shows it working with Ubuntu and, on bare metal, an NVIDIA DGX Spark running Ubuntu 24.04.5 LTS aarch64 on a
7.0.0-1025-nvidiakernel, with the hosted macOS using 4 CPUs and 8 GiB of RAM.
How to Try It
The README is truncated in this preview, so the exact build steps depend on the full documentation in the repository. What's clear from what's here:
- You'll need an arm64 Linux system with a stock distro kernel (Ubuntu is the demonstrated setup). The project is explicitly arm64-only based on the status section.
- You'll need a macOS 27 system disk made by Apple's own installer—the README says this boots to the desktop.
- Build the modules (
xnu.koandfki.ko) and load them withinsmod xnu.ko. - Expect CPU rendering by default; the GPU bridge is optional and gated behind
GPU=autoand a supported DRM bridge backend.
Check the repo for the full build instructions, kernel version requirements, and any CMA memory configuration you'll need to set up beforehand.
Final Thoughts
This is an experimental, deeply systems-level project—the kind that exists because someone wanted to know if it could be done. It's not going to replace your Mac anytime soon, and the truncated status section suggests the working configurations are narrow (two arm64 Linux setups, per the README). But as a demonstration of two kernels sharing CPUs, memory, and devices without a hypervisor, it's the kind of thing that makes you rethink where the line between "operating system" and "process" actually sits. If you're into kernel internals, MMU tricks, or just want to see sw_vers print Darwin on your Ubuntu box, this is worth a look.
Follow @githubprojects for more developer tools and open source projects.