Source: tobias-weiss-ai-xr/unkernel (GPL-2.0-or-later kernel, MIT SDK/page). Live demo: unkernel.dev. npm: unkernel.
Unkernel is Linux 7.x built as a single WebAssembly module with a real MMU. The kernel — syscalls, scheduler, memory management, ext4, TCP/IP — is compiled code, not emulated, so programs get Linux's own behaviour down to the edge cases. Only user programs are emulated: unmodified aarch64 (arm64) Linux binaries, so Alpine and Debian packages run as they are.
The result boots Alpine to a shell in roughly 0.3 s after node launches, downloads ~10 MB, runs in 48 MiB of guest memory, and works in Chrome, Edge, Firefox and Safari — including phones — with nothing to install and no server. A zero-dependency TypeScript SDK (MIT) lets you embed the same kernel in Node or the browser, with disks, networking, terminals, vsock, shared memory, framebuffer, audio and (in browsers) GL/Vulkan.
The design's central trick: keep the real Linux kernel running at native wasm speed, but run user code on kwemu, an aarch64 CPU written in Zig and linked into the kernel, which walks the kernel's own Sv48 page tables. Syscalls return straight into the kernel with no emulated trap in between. That gives you faithful Linux semantics and near-native syscall cost — getppid in ~170 ns versus ~1.7 µs under qemu-system.
Most "Linux in the browser" projects pick one of:
fork/MMU-dependent features break or are approximated.Unkernel keeps the best of each: the real Linux kernel at native wasm speed, under unmodified binaries with a real MMU. The comparison table from the project:
| Approach | Kernel | User space | MMU |
|---|---|---|---|
| Whole-machine emulators | Linux, emulated | unmodified, emulated | emulated |
| Syscall emulators | none (runtime reimplements) | unmodified, emulated | runtime's own |
| POSIX runtimes for wasm | none (runtime provides) | rebuilt for wasm / JS | none |
| Linux without MMU | Linux, native wasm | rebuilt for wasm | none |
| Unkernel | Linux, native wasm | unmodified aarch64, emulated | real page tables |
arch/wasm, derived from linux-wasm). The kernel's own code runs at wasm speed.WebAssembly.Suspending gives the kernel real stacks it can suspend and resume.kwblk (block), kwnet (network, user-mode TCP/IP stack in JS), kwfb/kwinput/kwsnd (display, input, sound), kwvsock, kwshm.The kernel carries a small base system (busybox + unkernel's tools) that mounts a distro image read-only under an overlay root and runs its init; createKernel() without a distro boots that base shell with no download.
Measured under Node:
| Operation | Native | qemu-user | qemu-system | Unkernel |
|---|---|---|---|---|
getppid | 110 ns | 320 ns | 1662 ns | 172 ns |
read 64 B from /dev/zero | 161 ns | 481 ns | 2247 ns | 172 ns |
| pipe write + read | 417 ns | 1032 ns | 7256 ns | 482 ns |
| fork + exit + wait | 73 µs | 537 µs | 1178 µs | 57 µs |
/init ~70 ms after start; Alpine prompt appears 0.3 s after node launches; ~10 MB download; 48 MiB guest memory.seq 100000 | sort -r 3.1 s vs 7.1 s).apk search ~0.8 s, apk add python3 ~3.4 s.fork, mmap, COW, shared memory, threads, signals behave as on hardware. Not a NOMMU port limited to vfork.multi-user.target./dev/fb0, evdev keyboard/mouse/touch, ALSA//dev/dsp sound, AF_VSOCK, shared memory with host.Browser: open unkernel.dev. ~10 MB download, desktop with a terminal. Changes persist in the browser. URL params: ?mem=512, ?net=0, ?jit=0, ?data=0, ?worker=0, ?cpus=2, ?gl=0, etc.
CLI:
npx unkernel
npx unkernel --distro debian
npx unkernel --distro none
npx unkernel --data my-data.img
npx unkernel --display --sound
npx unkernel --mem 1024 --no-net
npx unkernel --mount .:/work
npx unkernel --forward 8000:80
npx unkernel --timeout 60 --input '{8}uname -a\n{2}poweroff\n'
Exit codes: 0 power off, 1 halt/boot failure, 2 restart, 124 timeout, 253 panic, 254 wasm trap, 255 fatal.
Use npx unkernel in CI to run a real Linux environment: typed input on a schedule, timeout, exit code reflects guest outcome. Good for reproducing Linux-only bugs on macOS/Windows, or for integration tests that need apt packages.
import { createKernel, fetchDistro } from "unkernel";
const vm = await createKernel({ distro: await fetchDistro("alpine") });
vm.onOutput((bytes) => process.stdout.write(bytes));
vm.write("uname -a; poweroff\n");
const { code, kind } = await vm.exited; // 0, "halt"
The distro image downloads once from the GitHub release of the package's version (SHA-256 verified), cached in ~/.cache/unkernel. The kernel ships in the package (unkernel/unkernel.wasm).
Host the distro image yourself (served with range requests) and pass its URL:
const vm = await createKernel({ distro: "/distros/alpine.erofs" });
Networking goes through a Wisp proxy (or directBackend() in Node). Disks can be local ext4 images, http(s) images fetched by range, or a persistent disk in IndexedDB.
vm.exec(cmd, args, { input, cwd, env, user, encoding }) — runs on pipes, resolves with { stdout, stderr, exitCode, signal }.vm.spawn(file, args, { cols, rows, pty }) — pty or pipes, with resize(), kill(), close().vm.write() / vm.input / vm.output ReadableStream — console I/O.vm.sync() — flush guest disks; vm.stats() — memory/disk/network/JIT counters.MemoryFs (with change notifications), nodeFs(dir) (Node), or your own Fs implementation. Served over 9p on vsock; guest writes reach the host as they happen.vm.vsock.listen(port) / vm.vsock.connect(port) — byte streams with flow control, no network. vm.connect(port) reaches a guest TCP server on loopback over vsock./dev/shm access from host via vm.shm.open/create, with zero-copy views() when in-place.createAudioOut() for Web Audio in browsers.gl: true gives the guest Mesa/virgl rendering through the page's WebGL2. Debian: apt install mesa-utils libegl-mesa0 libgles2, then eglinfo.vk: true gives a Vulkan 1.2 driver backed by WebGPU (SPIR-V → WGSL via kwvk-naga.wasm).gpu: true with a kwvirtio kernel gives virtio-gpu with 3D; KMS clients get frames by texture, no readback.wland foot runs a Wayland app whose pixels come straight from guest memory.worker: true runs the kernel in a worker thread/Web Worker, keeping the event loop free. cpus: N boots an SMP kernel (each CPU in its own thread on shared memory); needs cross-origin isolation in browsers. checkSupport() verifies JSPI and friends before boot.
vm.connect(), vm.fetch(), --forward reach guest servers over vsock instead).echo hi | nc HOST PORT against a server that waits for EOF hangs; names resolve to placeholder addresses in 198.18.0.0/15.gdb watchpoints are software, single-stepping).npm startup) stays on the interpreter; FP/AdvSIMD runs through the interpreter even inside compiled code; without host wasm SIMD, OpenSSL's AES/SHA paths run on the interpreter.stop() doesn't shut down cleanly (prefer poweroff); Node-only TS projects need "lib": ["dom"] or skipLibCheck.Requires Linux (x86-64 or arm64), Zig 0.16, Node 24, clang 21+ with wasm target. First build ~12 min, ~5 GiB disk.
./setup.sh # check, then build everything
node js/cli.ts # boot your build
pnpm install && pnpm dev # web page at http://localhost:8080
zig build test # emulator tests
Produces vendor/build/bundle/unkernel.wasm and distro images vendor/build/distro/{alpine,debian}.erofs. See kernel/README.md, guest/README.md, and AGENTS.md.
js/, web/): MIT.MIT AND GPL-2.0-only (ships a GPL kernel + base system, plus MIT/GPL guest GL renderer and MIT/Apache-2.0 guest Vulkan translator).kernel/patches/linux (arch/wasm based on linux-wasm); patches and kernel/tools/fake-llvm are GPL-2.0-only; LLVM patches follow Apache-2.0 WITH LLVM-exception.Unkernel is the most credible "real Linux in the browser" I have seen: it does not reimplement Linux or rebuild your programs, it compiles the kernel to wasm and emulates only user space on a CPU that walks the kernel's own page tables. The payoff is faithful semantics with syscall costs close to native, plus a genuinely usable SDK for embedding a full Linux machine in a web page or Node process.
The honest caveats are the ones in section 8: CPU-heavy work is still far behind native, networking in the browser is Wisp-limited, and a kernel trap kills the session. For interactive shells, scripting, testing, and embedding Linux-backed features in web apps, those trade-offs are very reasonable — and the MIT SDK makes it shippable.
unkernel on npmarch/wasm origin