NEWS

unkernel project runs a real Linux kernel inside the browser via WebAssembly

unkernel compiles an entire Linux 7.x kernel to WebAssembly and boots an Alpine or Debian shell in under a second, with a real MMU and unmodified aarch64 binaries.

unkernel project runs a real Linux kernel inside the browser via WebAssembly
Image: Redação iMasters
News
Reading
5 min
Tables
1
Code
2

unkernel compiles an entire Linux 7.x kernel to WebAssembly and boots an Alpine or Debian shell in under a second, with a real MMU and unmodified aarch64 binaries.

A real Linux kernel, not a PC emulation

The unkernel project, published on GitHub by pithings, compiles the entire Linux 7.x kernel into a single WebAssembly module. It's not hardware emulation: the kernel code (syscalls, scheduler, memory management, ext4, TCP/IP stack) is compiled and runs as native wasm. Only the user space is emulated, and even then with unmodified aarch64 (arm64) binaries, so Alpine and Debian packages run exactly as they are.

In practice, opening a browser page delivers a complete Linux machine: shell, package manager, persistent disk, internet access, and even a screen with sound, all local, with no server and nothing to install. The entire project is open source; the SDK, specifically, is licensed under MIT.

How the kernel talks to aarch64 programs

The core of the design is separating two things that most "Linux in the browser" projects mix together: the kernel and the CPU that runs the user's programs. unkernel solves this with a piece called kwemu, an aarch64 CPU emulator written in Zig and embedded in the kernel itself.

When a program makes a system call, kwemu hands control back to the kernel, which handles the syscall as native wasm code, with no kernel-mode emulation layer in between. Task switching uses JSPI (WebAssembly.Suspending), which gives the kernel real execution stacks that can be suspended and resumed.

To speed things up, kwemu decodes guest code blocks into compact operations (whatever isn't optimized runs in a reference interpreter) and sends hot code paths to a second stage: a JIT that compiles these blocks into wasm modules at runtime, with output bit-for-bit identical to the interpreter's.

The comparison the project itself draws with other approaches helps put the difference in context:

ApproachKernelUser spaceMMU
Full machine emulators (v86, JSLinux, container2wasm)Emulated Linuxoriginal binary, emulatedemulated
Syscall emulatorsnone, runtime reimplements callsown runtimeruntime's own
POSIX runtimes for wasm (Wasmer WASIX, WebContainers)nonerecompiled to wasm or JavaScriptnone
Linux without MMU (linux-wasm, tombl/linux, WasmLinux/LKL)Native Linux in wasmrecompiled to wasmnone
unkernelNative Linux in wasmoriginal aarch64, emulatedreal page tables

Boot and syscall numbers

The README includes benchmarks measured under Node between November 14 and 18, 2026. The kernel reaches /init about 70 ms after starting, and the Alpine prompt appears 0.3 s after node is launched; the page downloads about 10 MB and Alpine boots with 48 MiB of guest memory.

System calls stay close to native cost: getppid takes about 170 ns (110 ns native, 1.7 µs running under qemu-system), and a 64-byte read also comes in around 170 ns. fork combined with exit and wait takes about 60 µs, versus 70 µs native and 1.2 ms under qemu-system.

The JIT changes the picture for hot code: a shell loop runs 1.6 times faster than on the pure interpreter, and a sort reaches up to 2.3 times faster. Inside the guest, OpenSSL does AES-128-GCM at about 100 MB/s and SHA-256 at about 160 MB/s, using aarch64's own AES, PMULL, and SHA hardware instructions.

Heavy CPU workloads still lag well behind native: an apk search on Alpine's main index takes about 0.8 s, and apk add python3 about 3.4 s.

How to run it: CLI, browser, and SDK

There are three ways to use the project. From the terminal, it's just:

npx unkernel
npx unkernel --distro debian
npx unkernel --mount .:/work
npx unkernel --forward 8000:80

The package loads the kernel and a minimal base system; the distro image is downloaded once from the GitHub release matching the installed version and cached locally. Without the --data flag, filesystem changes stay in memory only and disappear on exit.

In the browser, just open unkernel.dev: a desktop with a terminal appears, changes are saved in the browser itself, and URL parameters like ?mem=512, ?cpus=2, or ?net=0 adjust memory, CPUs, and networking. The project's compatibility table lists support on Chrome/Edge 137+, Firefox 153+, and Safari 27+ on macOS (any browser on iOS/iPadOS 27), all dependent on JSPI support.

To embed it in an application, the dependency-free TypeScript SDK installs with npm install unkernel:

js
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;

The same kernel file runs on Node and on any supported browser, optionally inside a worker. Disks can be local ext4 images, http(s) images read via range requests, or a persistent disk in IndexedDB in the browser.

What this changes for people building software

For those who need isolated, disposable environments, unkernel's proposal is direct: a complete Linux kernel, with a real MMU, running as a wasm module inside any process that already runs JavaScript. This opens the door to three concrete uses.

In short: client-side execution sandboxing (no server), test pipelines that spin up and tear down a full Linux VM in milliseconds, and distribution of command-line tools bundled with the application, with no dependency on a remote container. Since the SDK is MIT-licensed with no closed engine, it can be embedded in the product and hosted anywhere.

The SDK's exec() and spawn() API already covers the case of running an isolated binary and grabbing stdout/exitCode, useful for CI that needs a hermetic Linux environment without spinning up a virtual machine or a Docker container. Since browser networks don't open raw TCP sockets, traffic goes out through a Wisp proxy (wispBackend); on Node, the directBackend backend uses the host's sockets directly.

What's still missing

The README itself lists limitations that matter for security and production evaluation. There's no ptrace or seccomp, so strace and gdb don't work inside the guest. There are no inbound network connections (the alternative is vm.connect() or vm.fetch() via vsock), nor support for IPv6 or UDP beyond DHCP and DNS.

Snapshots of sessions with multiple CPUs (SMP) only resume with the same number of CPUs. Code that runs only a few times, like the startup of large programs (npm, for instance), stays stuck in the interpreter, and floating-point operations go through the interpreter even inside code already compiled by the JIT. A wasm trap inside the kernel ends the entire session, without the isolation a traditional hypervisor would offer between guest and host failures.

Translated from the Brazilian Portuguese original · Read the original