Post

A Real Linux Kernel Now Runs in Your Browser

Unkernel compiles the real Linux 7.3 kernel to WebAssembly and boots to a shell in about 0.3 seconds, right in a browser tab. Here is how it works, and what it cannot do yet.

A Real Linux Kernel Now Runs in Your Browser

Open a tab, wait about a third of a second, and you are looking at a Linux shell. Not a simulation of one, not a terminal wired to a server somewhere. A real Linux kernel, version 7.3.4, running inside your browser as WebAssembly, with a prompt ready before you have finished blinking.

The project is called unkernel, from developer Pooya Parsa, and it is the most interesting thing I have seen in the browser this year. I have watched a decade of “Linux in the browser” demos that turned out to be a slow emulator or a fake shell with a handful of canned commands. This one is neither. It hit the front page of Hacker News in mid-November, and after reading the README and an independent hands-on test, I think the attention is earned.

The trick is what it doesn’t emulate

Every earlier attempt picked one of three losing trades. Emulate a whole PC, kernel included, and everything is faithful but slow, because every syscall and page fault goes through emulated hardware. Emulate the CPU and reimplement the syscalls, and it is fast, but you only get as much of Linux as the runtime bothered to implement. Compile programs to wasm and hand them POSIX calls, and native programs have to be rebuilt, while fork and anything needing an MMU breaks.

Unkernel takes a fourth road: compile the actual kernel to wasm, and emulate only the user programs. The kernel, syscalls, scheduler, memory management, ext4, and the TCP/IP stack, runs as compiled WebAssembly code. The programs on top are unmodified aarch64 binaries, run by kwemu, a small ARM CPU emulator written in Zig and linked into the kernel itself. The kernel keeps a real MMU, with Sv48 page tables, so fork, mmap, copy-on-write, shared memory, threads, and signals behave the way they do on hardware. When a program makes a syscall, kwemu hands control back to the kernel, which handles it as native wasm. Task switches use JSPI, the WebAssembly feature that lets wasm code pause on an asynchronous wait and resume later, which is why the page needs a recent browser.

ApproachKernelUser programsMMU
Whole-machine emulators (v86, QEMU wasm)Linux, emulatedunmodified, emulatedemulated
Syscall emulatorsnone, a runtime reimplements itunmodified, emulatedthe runtime’s own
POSIX runtimes (WebContainers, Wasmer)nonerebuilt for wasmnone
Linux without an MMU (linux-wasm)Linux, native wasmrebuilt for wasmnone
unkernelLinux, native wasmunmodified aarch64, emulatedreal page tables

How unkernel fits together: Linux programs run on kwemu, an aarch64 CPU linked into the Linux kernel, built together into unkernel.wasm How the pieces fit: the kernel is native wasm, only user programs are emulated. (Diagram: unkernel project)

The practical payoff is that the slow parts of a system live in the kernel, and here that path runs at wasm speed. A fork is a kernel operation, so it is fast. Number crunching is user code, so it pays the emulation tax.

Fast where it counts, slow where it doesn’t

The project’s own numbers, measured under Node in mid-November: the kernel reaches /init about 70 ms after it starts, and the Alpine prompt appears 0.3 seconds after node launches. The page downloads about 10 MB, and Alpine boots in 48 MiB of guest memory. An independent test timed it a touch slower, /init at 94 ms and the prompt at 231 ms, which is the same ballpark and close enough that I trust the headline claim.

Fork plus exit plus wait takes about 60 microseconds, against about 70 microseconds natively and 1.2 milliseconds under qemu-system. A getppid call costs about 170 nanoseconds, against 110 native and 1.7 microseconds under QEMU. The honest reading is simple: kernel operations run at essentially native speed.

Time per operation for native, qemu-user, qemu-system, and unkernel Syscalls and fork run at close to native cost; the gap opens up on pure computation. (Chart: unkernel project)

CPU-heavy user code is the other side of the coin, and the README is candid about it. A shell loop runs 1.6 times as fast with the JIT as on the interpreter alone, sort 2.3 times, and OpenSSL in the guest manages AES-128-GCM at about 100 MB/s. But apk search over the main index still takes about 0.8 seconds, and apk add python3 about 3.4 seconds. If your workload is starting processes, opening files, and shuffling data through pipes, this thing flies. If it is crunching numbers, it crawls.

Three ways to try it

The easiest is the browser. Open unkernel.dev, and after a download of about 10 MB you get a desktop with a terminal. The live site boots Debian 13 into a small Wayland desktop with a couple of virtual CPUs, and yes, you can run Doom on it, because of course someone tried that first. Your changes persist in the browser, and URL parameters tune the machine: ?mem=512 for guest memory, ?cpus=2 for CPUs, ?net=0 to boot without a network. Browsers cannot open raw TCP sockets, so the page reaches the internet through a Wisp proxy, which sees connection addresses and the bytes on plain HTTP, though HTTPS streams stay opaque to it.

From a terminal it is one command, and I like this version best, because it feels like a tool rather than a demo:

1
2
3
4
npx unkernel
npx unkernel --distro debian
npx unkernel --mount .:/work
npx unkernel --forward 8000:80

The first run downloads the Alpine image, about 4 MB, from the GitHub release and caches it in ~/.cache/unkernel. Debian 13 is a 57 MB download instead, with apt. --mount puts your current directory at /work inside the guest over 9p, and --forward reaches a server on the guest’s loopback from your host, which is how you would actually develop against it. Press Ctrl-] to quit.

The third way is the one I think matters most, and it is the reason this article sits in Dev Tools rather than Linux. The TypeScript SDK installs with npm install unkernel, has zero dependencies, and the same kernel file runs in Node and in every supported browser, optionally in a worker:

1
2
3
4
5
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");

vm.exec() runs a program and resolves with its stdout, stderr, and exit code. vm.spawn() gives you a pty. vm.connect() reaches a TCP server on the guest’s loopback over vsock, with no network in between, and vm.fetch() talks HTTP to a dev server inside the guest. That is a Linux machine as a library call. The demo that followed within days, Trynix, runs NixOS on top of unkernel instead of Alpine or Debian, which puts most of the Nix package collection a tab away.

What it can’t do yet

A project this young has sharp edges, and the README lists them plainly, which I respect. There is no IPv6, no ICMP beyond the gateway, and no UDP on the web page beyond DHCP and DNS. There are no inbound network connections at all; you reach guest servers over vsock instead. gdb works, but its hardware watchpoints are software ones that single-step the program. A wasm trap in the kernel ends the session outright. The CLI boots one CPU by default, while the page boots several where it can.

Then there is the browser floor. JSPI is a hard requirement, so you need Chrome or Edge 137 or newer, Firefox 153 or newer, or Safari 27 or newer on macOS. Older browsers get a page that tells them what is missing, which is the polite version of “no.” And the whole thing is two weeks old as I write this. The repo appeared in mid-November, version 0.2 landed on November 19, and the kernel build in the current release dates from November 24.

My take

What sold me is not the demo, fun as it is. It is the SDK. A bootable, scriptable Linux that arrives as an npm package changes who can ship a Linux-shaped thing. A tutorial site can give every reader a real shell with no signup and no server bill. A developer tool can run a user’s build in a real kernel instead of reimplementing half of POSIX. A classroom can hand out identical Linux machines by sending a link.

I would not replace anything with it today. The CPU tax is real, the networking limits are real, and a two-week-old project is not where you put work you cannot afford to lose. But the direction is right, and the design is honest about its trade in a way most demos are not: it is fast exactly where a kernel should be fast, and slow exactly where emulation should be slow. Open unkernel.dev in a tab and type uname -a. The moment the guest answers with its own kernel version, you will understand why people are excited. I did.

Frequently asked questions

Is it really the Linux kernel, or just an emulator pretending to be one?

It is the real kernel. Unkernel compiles Linux 7.3 to a single WebAssembly module, so syscalls, the scheduler, memory management, ext4, and the TCP/IP stack all run as compiled code. Only the user programs on top are emulated, as unmodified aarch64 binaries. The guest reports itself as Linux 7.3.4, and /proc, epoll, cgroups, and overlayfs all behave the way they do on a server.

What do I need to run it?

A recent browser with JSPI support: Chrome or Edge 137 or newer, Firefox 153 or newer, or Safari 27 or newer on macOS. Then just open unkernel.dev. From a terminal, npx unkernel boots Alpine with no install step, and npm install unkernel gives you the TypeScript SDK for embedding it in your own app.

Can I install packages and use it as my daily machine?

You can install real packages, Alpine with apk or Debian 13 with apt, and the live page even boots a small Wayland desktop. But it is not a desktop replacement. CPU-heavy work runs well behind native speed, there is no IPv6, no UDP on the web page beyond DHCP and DNS, and no inbound network connections. Think of it as a Linux machine you can carry in a tab, not the laptop your work lives on.

Is it free and open source?

Yes, every layer is open source. The kernel build is GPL, the JavaScript SDK is MIT licensed with no closed engine or license key behind it, and the distro images come straight from Alpine and Debian. You can host the page yourself and point it at your own Wisp proxy.

Written by
Priya Nair Developer Tools and Cloud Editor

Covers editors, terminals, CI, hosting, and cloud platforms. Every tutorial is run end to end on a clean setup before it is published, with the failures left in.

Get the next article by email

Three new loop and stack articles every day, Monday to Sunday. Subscribe and follow.it emails you when one lands. No spam, unsubscribe anytime.

New articles, straight to your inbox
Comments
This post is licensed under CC BY 4.0 by the author.