Running macOS kernel as a Linux module on arm64 hardware
The xnulinux project loads Apple's XNU kernel as a module inside Linux, allowing macOS userspace to run natively alongside Linux processes without a hypervisor.
A new open-source project called xnulinux enables the macOS kernel to run directly inside an unmodified arm64 Linux kernel. Released in late 2023, this technical achievement allows macOS userspace applications to execute natively on the same CPUs as Linux processes, bypassing traditional virtualization layers. The project builds XNU, Apple’s open-source kernel, from published sources and loads it as a kernel module named xnu.ko.
What happened
The xnulinux repository demonstrates that it is possible to boot a full macOS 27 system disk within a standard Linux environment. By using a stock Ubuntu kernel, developers can load the xnu.ko module and start a macOS desktop environment that includes standard components like loginwindow, WindowServer, Dock, Finder, Safari, and Chrome. This setup does not rely on a hypervisor; instead, the hosted XNU kernel drives the CPU and memory management unit directly.
The project has been tested successfully on two primary arm64 Linux configurations. On an Apple Silicon Mac running an arm64 Linux virtual machine via krunkit, macOS 27.2.1 boots to the desktop in 31 to 48 seconds. This performance is comparable to, and in some cases faster than, a native Apple Virtualization macOS VM on the same hardware. The system remains stable during stress tests involving multiple applications and file system operations.
On bare-metal hardware, specifically an NVIDIA DGX Spark running Ubuntu 24.04.5 LTS with Linux kernel 7.0, the system also boots to a full macOS desktop. In this configuration, four CPUs and 8 GiB of RAM are reserved for the hosted XNU kernel. While the desktop environment functions correctly with Screen Sharing and SSH access, graphics rendering currently falls back to CPU-based methods because the GPU bridge does not yet support direct hardware pass-through for the GB10 GPU.
How it works
The architecture relies on a small interface module called fki.ko, which acts as a bridge between the Linux host and the macOS guest. Linux provides essential resources such as memory, timers, files, network access, and GPU capabilities through this interface. Each hosted CPU in the macOS environment corresponds to a pinned Linux kernel thread. XNU runs on these threads until it needs to perform idle tasks, input/output operations, or handle timers, at which point it calls back to the Linux host.
Memory management is handled by allocating a physically contiguous block from Linux using Contiguous Memory Allocator (CMA). XNU manages this memory with its own page map, sharing the user half of the address space layout with Linux using 4K pages. Device access is mediated by kernel extensions (kexts) that present virtualized hardware to macOS, including a disk backed by a Linux file, a framebuffer for display, and an Ethernet link tied to a Linux network interface.
Graphics acceleration uses a translation layer where Metal commands in macOS are converted to Vulkan via metal2vulkan. These Vulkan commands are then passed to the Linux host’s GPU through a DRM bridge using Mesa’s Venus driver. If a compatible render node is not available, the system defaults to Mesa lavapipe for CPU-based rendering. This complex stack ensures that graphical applications can function, albeit with varying levels of hardware acceleration depending on the host configuration.
Key details
- Kernel Module Approach: XNU runs as
xnu.ko, an APSL-2.0 licensed module, while the interfacefki.kois GPL-2.0 licensed, keeping the codebases legally distinct. - Hardware Requirements: The host must be arm64 Linux with Pointer Authentication Codes (PAC) support, 4K pages, and at least 16 GB of RAM, with 8 GB reserved for the hosted kernel.
- Performance: On Apple Silicon M-series chips, boot times range from 31 to 48 seconds, with successful completion of 30-minute stress tests involving Safari, Notes, and System Settings.
- GPU Support: Hardware acceleration is available via Virtio-GPU Venus on supported virtual machines, but bare-metal NVIDIA setups currently rely on CPU rendering due to missing DRM bridge backends.
- System Integrity: The project requires relaxing System Integrity Protection (SIP) and patching AMFI, with the OS cryptex merged into the system volume.
- No Distributed Binaries: The repository contains no Apple binaries; users must provide their own macOS 27 installation disk and build the kernel from Apple’s published sources.
Why it matters
For infrastructure engineers and systems researchers, xnulinux offers a novel method for studying kernel interactions and cross-platform compatibility without the overhead of full virtualization. By running two different userspaces on the same kernel, developers can analyze how distinct operating system personalities share resources. This could lead to more efficient resource utilization in mixed-environment data centers where both Linux and macOS tools are required.
The project also highlights the flexibility of the Linux kernel module system and the modularity of XNU. It demonstrates that significant portions of macOS can be decoupled from Apple’s proprietary hardware stack and run on generic arm64 Linux servers. This has implications for cloud providers looking to offer macOS-like environments on non-Apple hardware, although legal and licensing constraints remain significant barriers to commercial adoption.
What you can do
- Review the xnulinux repository on GitHub to understand the build scripts and kernel patches required for compilation.
- Set up an arm64 Linux environment with PAC support and at least 16 GB of RAM to test the module loading process.
- Use Apple’s installer to create a macOS 27 system disk within a virtual machine for use as the hosted root filesystem.
- Experiment with the
fki.kointerface to observe how Linux handles memory and timer requests from the hosted XNU kernel. - Monitor the project’s documentation for updates on GPU bridge support, particularly for bare-metal NVIDIA hardware.
- Contribute to the open-source community by testing the systemd service integration and reporting stability issues during stress runs.



