Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

AFK-surf/xnulinux

System Tools

Runs a macOS 27 system disk directly on arm64 Linux by loading Apple's XNU kernel as a kernel module beside Linux.

776
28
Objective-C++
NOASSERTION
3 days old

Overview

xnulinux builds XNU, the open-source kernel of macOS, from Apple's published sources and loads it as an out-of-tree kernel module (xnu.ko) inside a stock arm64 Linux kernel. Instead of virtualizing macOS, the hosted XNU runs on real CPUs and manages its own memory, while a companion GPL module (fki.ko) lends it CPU threads, physically contiguous memory, faults, files, networking and GPU access through a small interface called FKI. macOS processes therefore run natively next to Linux processes on the same CPUs, with no hypervisor in between.

The visible result is a working macOS desktop: loginwindow, WindowServer, Dock, Finder, Safari and Chrome boot from a macOS 27 installation disk to the desktop. A small set of kexts under kexts/ gives the hosted system a disk backed by a Linux file, a framebuffer, keyboard and pointer input, an Ethernet link over a Linux network interface, a keystore and an optional GPU bridge. Metal inside macOS is translated through gpu/xnu-cpu-metal (metal2vulkan over Vulkan), reaching the host GPU via the DRM bridge, or falling back to Mesa lavapipe on the CPU.

This is aimed at people who want to study or experiment with macOS internals on Linux hardware and are comfortable building kernels and handling macOS installation media. It is not a drop-in virtual machine.

How it works

Each hosted CPU is a Linux kernel thread pinned to a Linux CPU; XNU runs on it until it needs the host. Linux keeps its own exception vectors, and fki.ko forwards XNU code faults and user exceptions to XNU's handlers. XNU receives one physically contiguous block of memory from Linux (CMA) and manages it with its own pmap, sharing the user half of the address space with Linux at 4K pages.

The two sides are separated by license: fki.ko and the in-tree driver are GPL-2.0-only, while xnu.ko, the XNU patches and host kexts are APSL-2.0. xnu.ko calls Linux only through the fki_* interface and is reported as a non-GPL module, which taints the kernel.

Getting started

The build is a four-part process: build XNU, patch and link the kernel collection with Apple kexts from your own macOS installation, convert a macOS VM disk into the hosted system disk, and boot it.

  1. In the arm64 Linux VM, run scripts/vm-xnu-build.sh once to set up the macOS-DroidVM toolchain and build XNU (xnu-12377.121.6) natively.
  2. Run scripts/vm-xnu-rebuild.sh to apply xnu-patches/, build the kernel and kexts/, and link the kernel collection using the Apple kexts from your macOS installation.
  3. On the Mac, run scripts/mk-macvm-disk.sh to turn a macOS VM disk made by Apple's installer into the hosted system disk, then copy it into the Linux VM.
  4. In the Linux VM, run scripts/xnulinux-boot.sh to build fki.ko and xnu.ko against the running kernel, bring up networking (and the GPU bridge when a render node exists) and boot the hosted system. Use scripts/xnu-console.sh for the console, tools/hosted/fb2png.py for the screen and tools/hosted/xnu-input.py for input.

To run it as a service, scripts/install-service.sh installs xnulinux.service, configured in /etc/xnulinux.conf (CPUs, memory, disk, GPU), while scripts/install-krun-agent.sh on the Mac keeps the VM running. GPU support is optional and is built on the Mac with gpu/venus/build-darwin.sh and gpu/xnu-cpu-metal/.

The repository contains no Apple binaries: the macOS system disk, its trust cache and Apple's kexts must come from an installation you own.

Requirements and limits

  • An arm64 Linux host with PAC support (Apple Silicon M1 or later inside a VM, e.g. krunkit for GPU access or tart), 4K pages and 16 GB of RAM, 8 GB of which is reserved for the hosted kernel.
  • A Mac with Xcode for building the system disk and the GPU components.
  • Your own macOS 27 installation, such as an Apple Virtualization VM disk.
  • 1 to 6 hosted CPUs are supported in the tested configuration; macOS boots to the desktop with auto-login in 31–48 s, comparable to a native Apple Virtualization macOS VM at 49 s in the same test.
  • Several pieces are explicitly temporary: the OS cryptex is merged into the system volume, AMFI is patched and SIP relaxed, and memory access is slower than a native VM because of 4K pages versus 16K. Remaining stopgaps are tracked in the production notes.
  • xnu.ko taints the kernel as a non-GPL module, and the license split is documented in the license texts.

HotRepo's take

On 2026-11-23 the project entered HotRepo's new-project list with 116 stars gained over a roughly one-hour window and 253 stars total, and a Hacker News thread drew 115 points and 46 comments discussion. Much of that discussion is about the idea of running Apple's kernel and GUI on Linux rather than about the build: one commenter asks whether the same module approach could work for Windows comment, and another replies that CoLinux once ran Linux and Windows simultaneously comment; others express surprise that this kind of cross-kernel work has become practical comment. One reply to a remark about hardware-locked OS binaries points out that XNU itself is open source comment, which is the foundation the project builds on. The thread is a signal of interest in the approach; the README's own measurements are the only performance evidence provided.

Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.

Hacker News

XNU Linux: Full OS X GUI Userspace on Linux
▲ 115 · 46 comments · November 23, 2026

You might also like

  1. oosexgang/hackios-xnu-kernelPort of Apple's open-source Darwin XNU kernel to Android phones, with its own loader and drivers, running from RAM.C2,726
  2. dipa-studio/ios-sweetBoots Apple's XNU kernel and an unmodified iOS 16 userland on a Redmi Note 10 Pro, for kernel porting experimenters.Python1,029
  3. UniXNU/UniXNUBoots iOS and macOS on non-Apple ARM64 devices via a UEFI layer, aimed at porters and tinkerers.Python899
  4. opencecs/teboxRuns generic ARM64 Android GSI images on QEMU with GPU acceleration for Apple Silicon, Linux and Windows hosts.C92
  5. ammaarreshi/WindowsiOSRuns unmodified Windows 11 ARM64 on non-jailbroken iOS devices via an ARM64-to-ARM64 JIT and a custom virtual PC platform.C113