[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115003":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},115003,"unkernel","pithings\u002Funkernel","pithings","A real Linux kernel, compiled to WebAssembly. It boots to a shell in less than a second.","https:\u002F\u002Funkernel.dev",null,"TypeScript",1418,72,1,8,0,259,1137,1176,103.46,"GNU General Public License v2.0",false,"main",[],"2026-11-23 11:26:49","2026-11-23 20:44:26","\u003Ch1 align=\"center\">\u003Cimg alt=\"unkernel\" src=\"assets\u002Flogo-wordmark.svg\" width=\"400\">\u003C\u002Fh1>\n\n**A real Linux kernel, compiled to WebAssembly. It boots to a shell in less than a second.**\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Funkernel.dev\u002F\">\u003Cb>Try it\u003C\u002Fb>\u003C\u002Fa> ·\n  \u003Ca href=\"#-performance\">Performance\u003C\u002Fa> ·\n  \u003Ca href=\"#-a-real-kernel\">Features\u003C\u002Fa> ·\n  \u003Ca href=\"#-run-it-from-the-terminal\">CLI\u003C\u002Fa> ·\n  \u003Ca href=\"#-how-it-works\">How it works\u003C\u002Fa> ·\n  \u003Ca href=\"#-benchmarks\">Benchmarks\u003C\u002Fa> ·\n  \u003Ca href=\"#-use-it-from-javascript\">JavaScript SDK\u003C\u002Fa>\n\u003C\u002Fp>\n\nunkernel is Linux 7.x built as a single wasm module with a real MMU. The\nkernel (syscalls, scheduler, memory management, ext4, TCP\u002FIP) is compiled\ncode, not emulated, so programs get Linux's own behavior down to the edge\ncases. Only user programs are emulated, with a JIT: unmodified riscv64\nLinux binaries, so Alpine and Ubuntu packages run as they are.\n\n[Open a page](#-try-it-in-the-browser) and you have a Linux machine with a\nshell, a package manager, a persistent disk, internet access, and a screen\nwith sound. It runs entirely on your device, with nothing to install and no\nserver, and every layer is open source. [How it works](#-how-it-works)\nexplains the design.\n\n\u003Cp align=\"center\">\n  \u003Cimg alt=\"Linux programs run on kwemu, a riscv64 CPU linked into the Linux kernel, built together into unkernel.wasm, which talks to the JavaScript SDK\" src=\"assets\u002Farchitecture.svg\" width=\"760\">\n\u003C\u002Fp>\n\n## ⚡ Performance\n\nMuch of what makes a system feel slow lives in the kernel: starting\nprocesses, syscalls, page faults, file and network I\u002FO. In unkernel that\npath runs at wasm speed.\n\n- **Boot**: the kernel reaches `\u002Finit` about 70 ms after it starts, and the Alpine\n  prompt appears 0.3 s after `node` launches. The page downloads about\n  10 MB, and Alpine boots in 48 MiB of guest memory.\n- **Syscalls at close to native cost**: `getppid` takes about 170 ns (110\n  native, 1.7 µs under qemu-system), a 64-byte `read` about 170 ns (160\n  native).\n- **fork at native speed**: fork + exit + wait takes about 60 µs, against\n  about 70 µs natively and 1.2 ms under qemu-system.\n- **A JIT for user code**: hot riscv64 code is compiled to wasm while it\n  runs. A tight loop takes 2.5 ns per iteration (1.8 native, 28 without the\n  JIT), and https downloads in the guest reach 30 MB\u002Fs.\n\nCPU-heavy programs are still well behind native. [Benchmarks](#-benchmarks)\nhas the full numbers.\n\n## 🐧 A real kernel\n\nAnything a program relies on, from `\u002Fproc` and `epoll` to cgroups and\noverlayfs, behaves as it does on a server, because it runs the same code.\n\n- **A real MMU** (`arch\u002Fwasm` with Sv39 page tables): `fork`, `mmap`,\n  copy-on-write, shared memory, threads and signals behave as they do on\n  hardware. This is not a NOMMU port where programs are limited to `vfork`.\n- **Linux's own file systems**: ext4, overlayfs, tmpfs, loop devices, FUSE,\n  and 9p, which [mounts file systems](#mount-host-files) your program serves\n  from the host. In the browser the root file system is an overlay on a\n  persistent ext4 disk, so everything you change survives a reload, and a safe\n  mode recovers a system you broke.\n- **Linux's own TCP\u002FIP stack**, with DHCP and DNS, reaching the internet\n  through your host's sockets or a Wisp proxy\n  ([Add a network](#add-a-network)).\n- **cgroups, namespaces, userfaultfd, fanotify and TUN**: enough for\n  systemd to boot Ubuntu 24.04 to `multi-user.target`.\n- **Devices**: a [framebuffer (`\u002Fdev\u002Ffb0`), evdev keyboard, mouse and touch,\n  sound through ALSA and `\u002Fdev\u002Fdsp`](#display-input-and-sound),\n  [AF_VSOCK](#talk-over-vsock), and [shared memory](#share-memory) with the\n  host.\n- **riscv64 user space**: RV64GC plus Zba, Zbb, Zbs, Zbc, Zbkb, Zbkc, Zbkx,\n  Zkne, Zknd, Zicond and the scalar rest of RVA23U64, so distribution\n  binaries and OpenSSL's AES and carry-less multiply paths run unchanged.\n  riscv64 is a modern 64-bit architecture with official ports in Alpine,\n  Debian and Ubuntu, so their full, current package archives are available.\n\n[Known limits](#-known-limits) lists what is still missing.\n\n## 🧰 What you can do with it\n\n- **[Carry a Linux shell anywhere](#-try-it-in-the-browser).** Alpine Linux\n  3.24 runs in Chrome, Edge, Firefox and Safari, including on phones. Install\n  anything with `apk add` from Alpine's regular mirrors. Type a command that\n  isn't installed, such as `htop`, and its package is installed for you. apk\n  starts with only the `main` repository, because it is about 4x faster that\n  way; `community` is added the first time a command needs it.\n- **Run real runtimes and tools**: Node and npm, Python, OpenSSL, curl and\n  `wget`, straight from the distribution. Ubuntu 24.04 boots from a disk,\n  with apt and, once you install it, systemd.\n- **[Write graphics and sound programs](#display-input-and-sound)** against\n  `\u002Fdev\u002Ffb0`, evdev and ALSA. Try `glimmer`, a tiny game with sound.\n- **[Embed Linux in your app](#-use-it-from-javascript)** with a\n  zero-dependency TypeScript SDK, published as\n  [`unkernel`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Funkernel). The same kernel file\n  runs in Node and in every supported browser, optionally [in a\n  worker](#run-it-in-a-worker). [Disks](#add-disks) can be local ext4 images,\n  http(s) images fetched by range, or a persistent disk in IndexedDB. The SDK\n  is MIT-licensed, and there is no closed engine or license key behind it, so\n  you can ship it in your product and host it wherever you like.\n- **Talk to the guest** through [terminal sessions](#run-programs), each\n  with its own pty and shell, [host directories and in-memory file\n  systems](#mount-host-files) mounted in the guest, [vsock byte\n  streams](#talk-over-vsock) and [zero-copy shared memory](#share-memory),\n  with no network in between.\n- **Script and test**: [the CLI](#-run-it-from-the-terminal) types input on a\n  schedule, stops on a timeout, and reports how the guest ended in its exit\n  code.\n\n## 🌐 Try it in the browser\n\nOpen **[unkernel.dev](https:\u002F\u002Funkernel.dev\u002F)**. A shell appears\nafter a download of about 10 MB. Your changes are saved in the browser, and\nthe status icon opens options, diagnostics, and export or reset for your\ndisk. Ctrl-A n (or ⌘A n on a Mac) or `+` on the status line opens another\nterminal window with its own shell, up to 9; Ctrl-A and a digit switches.\n\nThe page takes a few URL parameters:\n\n| Parameter | Does |\n| --- | --- |\n| `?mem=512` | Guest memory in MiB |\n| `?append=...` | Extra kernel command line |\n| `?net=0` | Boot without a network |\n| `?wisp=wss:\u002F\u002F...` | Use your own [Wisp](https:\u002F\u002Fgithub.com\u002FMercuryWorkshop\u002Fwisp-protocol) proxy |\n| `?jit=0` | Interpreter only |\n| `?data=0` | No persistent disk, a fresh system every time |\n| `?worker=1` | Run the kernel in a Web Worker (experimental) |\n| `?smp=2` | Boot on several CPUs, each in a Web Worker (experimental; only where the page has the SMP kernel and is cross-origin isolated) |\n\nBrowsers can't open raw TCP sockets, so the page reaches the internet\nthrough a Wisp proxy. The default one accepts only known origins, so if you\nhost the page somewhere else, point `?wisp=` at your own proxy.\n\n| Browser | Status |\n| --- | --- |\n| Chrome \u002F Edge 137+ (desktop and Android) | ✅ works |\n| Firefox 153+ | ✅ works |\n| Safari 27+ on macOS, any browser on iOS\u002FiPadOS 27 | ✅ works |\n| Anything without [JSPI](#-how-it-works) | the page tells you what's missing |\n\n## 💻 Run it from the terminal\n\n```sh\nnpx unkernel\n```\n\nThis boots Alpine from RAM, with networking over your host's sockets. Press\n**Ctrl-]** to quit.\n\n```sh\nnpx unkernel --disk alpine.ext4              # boot from an ext4 image, changes persist\nnpx unkernel --data my-data.img              # a persistent \u002Fdata disk, created on first use\nnpx unkernel --display --sound               # a framebuffer and a sound card\nnpx unkernel --mem 1024 --no-net             # more memory, no network\nnpx unkernel --mount .:\u002Fwork                 # this directory at \u002Fwork in the guest (:ro for read-only)\nnpx unkernel --forward 8000:80               # host 127.0.0.1:8000 to port 80 in the guest\nnpx unkernel --timeout 60 --input '{8}uname -a\\n{2}poweroff\\n'   # scripted: wait, type, wait, type\nnpx unkernel --help                          # everything else\n```\n\nExit codes: 0 power off, 1 halt or boot failure, 2 restart, 124 timeout, 253\nkernel panic, 254 wasm trap, 255 fatal error. The CLI is built on the\n[JavaScript SDK](#-use-it-from-javascript): `--mount` uses its [host\nmounts](#mount-host-files) and `--forward` its\n[`vm.connect()`](#talk-over-vsock).\n\n## 🔍 How it works\n\nMost \"Linux in the browser\" projects take one of three approaches:\n\n- **Emulate a whole PC**, kernel included. This is faithful but slow,\n  because every syscall and page fault goes through emulated hardware.\n- **Emulate the CPU and reimplement the syscalls.** Programs run on an\n  emulated CPU, often with a JIT, and a runtime answers their syscalls, with\n  no Linux kernel at all. This is fast, but it covers only as much of Linux\n  as the runtime implements.\n- **Compile programs to wasm**, and run them on a kernel without an MMU or\n  on a runtime that provides POSIX calls. This is fast, but native programs\n  have to be rebuilt, and `fork` and anything else that needs an MMU breaks\n  or is approximated.\n\nunkernel keeps the best of each: the real Linux kernel, running at native\nwasm speed, under unmodified binaries with a real MMU.\n\n| Approach | Kernel | User space | MMU |\n| --- | --- | --- | --- |\n| Whole-machine emulators (v86, JSLinux, container2wasm, QEMU's wasm build) | Linux, emulated | unmodified, emulated | emulated |\n| Syscall emulators | none: a runtime reimplements the syscalls | unmodified, emulated | the runtime's own |\n| POSIX runtimes for wasm (Wasmer WASIX, WebContainers, BrowserPod) | none: a runtime provides the syscalls | rebuilt for wasm, or JavaScript | none |\n| Linux without an MMU (linux-wasm, tombl\u002Flinux, WasmLinux (LKL)) | Linux, native wasm | rebuilt for wasm | none |\n| **unkernel** | **Linux, native wasm** | **unmodified riscv64, with a JIT** | **real Sv39 page tables** |\n\nThe kernel is compiled straight to WebAssembly. User programs run on\n**kwemu**, a riscv64 CPU written in Zig and linked into the kernel. kwemu\nwalks the kernel's own page tables, so memory management is done by the\nreal Linux code.\n\nWhen a program makes a syscall, kwemu returns to the kernel, which handles\nit as native wasm. There is no emulated trap and no emulated kernel mode in\nbetween. Task switches use JSPI (`WebAssembly.Suspending`), so the kernel\ngets real stacks that it can suspend and resume.\n\nHot user code goes through a second tier: a JIT that compiles riscv64 to\nwasm modules at run time, with output that matches the interpreter bit for\nbit. [Benchmarks](#-benchmarks) shows what each tier costs.\n\nDevices are small paravirtual drivers that talk to the JavaScript host:\n[block](#add-disks) (kwblk), [network](#add-a-network) (kwnet, with a\nuser-mode TCP\u002FIP stack in JS), [display, input and\nsound](#display-input-and-sound) (kwfb, kwinput, kwsnd),\n[vsock](#talk-over-vsock) (kwvsock) and [shared memory](#share-memory)\n(kwshm).\n\n### 📊 Benchmarks\n\nThe design helps most with syscalls. These were measured under Node:\n\n\u003Cp align=\"center\">\n  \u003Cimg alt=\"Time per operation for native, qemu-user, qemu-system and unkernel: getppid 110, 320, 1662 and 172 ns; read 64 B from \u002Fdev\u002Fzero 161, 481, 2247 and 172 ns; pipe write + read 417, 1032, 7256 and 482 ns; fork + exit + wait 73, 537, 1178 and 57 µs\" src=\"assets\u002Fperformance.svg\" width=\"760\">\n\u003C\u002Fp>\n\nIn this test fork is faster than native. Pure computation is slower. The JIT\nruns a tight integer loop at about 3900 MIPS (about 270 interpreted), and\nreal Alpine work (`sort`, `gzip`, `sha256sum`, `awk`) runs 1.7 to 4.6 times\nfaster than without it, which is still well behind native.\n\n### 🚧 Known limits\n\n- One CPU in the released kernel. Several CPUs (SMP) are experimental,\n  not in a release yet, and cannot be suspended.\n- No IPv6, no UDP beyond DHCP and DNS, no inbound network connections\n  ([`vm.connect()`, `vm.fetch()`](#talk-over-vsock) and `--forward` reach\n  guest servers over vsock instead).\n- No ptrace register sets, so `strace` and `gdb` don't work. No seccomp.\n- The JIT leaves atomics and system instructions to the interpreter.\n- A wasm trap in the kernel ends the session.\n\n## 🧩 Use it from JavaScript\n\n```sh\nnpm install unkernel\n```\n\n```js\nimport { createKernel } from \"unkernel\";\n\nconst vm = await createKernel();                 \u002F\u002F bundled Alpine, no network\nvm.onOutput((bytes) => process.stdout.write(bytes));\nvm.write(\"uname -a; poweroff\\n\");\n\nconst { code, kind } = await vm.exited;          \u002F\u002F 0, \"halt\"\n```\n\nThe same code runs in the browser. Importing `unkernel` picks the Node or\nbrowser entry automatically, and `unkernel\u002Fnode` or `unkernel\u002Fweb` selects\none explicitly. The kernel ships in the package and loads from next to the\nentry, streamed and compiled while it downloads.\n\n### Add a network\n\n```js\nimport { createKernel, directBackend, wispBackend, DEFAULT_WISP_SERVERS } from \"unkernel\";\n\nawait createKernel({ net: directBackend() });                       \u002F\u002F Node: host sockets\nawait createKernel({ net: wispBackend(DEFAULT_WISP_SERVERS) });     \u002F\u002F anywhere: a Wisp proxy\n```\n\nNetworking is off unless you pass `net`. Any object with `connect` and\n`lookup` methods can carry the guest's TCP and DNS, so you can write your\nown backend.\n\n### Add disks\n\n```js\nimport { createKernel, openDisk } from \"unkernel\u002Fnode\";\n\nconst vm = await createKernel({\n  disks: [await openDisk(\"alpine.ext4\")],        \u002F\u002F or an https:\u002F\u002F URL\n  cmdline: \"root=\u002Fdev\u002Fwda rw\",\n});\n```\n\nIn the browser, `openHttpDisk(url)` keeps your writes in IndexedDB and\n`openDataDisk()` gives you the persistent data disk that\n[the page](#-try-it-in-the-browser) uses. Anything that\nimplements `BlockDevice` works too.\n\n### Console and lifecycle\n\n```js\n\u002F\u002F vm.output: a ReadableStream, everything since boot and then live\nvm.output.pipeTo(new WritableStream({ write: (b) => process.stdout.write(b) }));\nvm.write(\"ls \u002F\\n\");                              \u002F\u002F or write to vm.input, a WritableStream\nvm.resize(120, 40);                              \u002F\u002F the foreground program gets SIGWINCH\n\nawait vm.sync();                                 \u002F\u002F flush the guest's disks\nconsole.log(vm.stats());                         \u002F\u002F memory, disk, network and JIT counters\nconst { code, reason, kind } = await vm.exited;  \u002F\u002F stop() parks it at once\n```\n\n### Run programs\n\n```js\nconst { stdout, exitCode } = await vm.exec(\"uname\", [\"-a\"]);\nconst { stdout: sum } = await vm.exec(\"sha256sum\", [], { input: \"hello\" });\n```\n\n`exec()` runs a program on pipes and resolves with `{ stdout, stderr,\nexitCode, signal }`, also for a non-zero exit. Pass `encoding: \"buffer\"`\nfor bytes, and `cwd` or `env` as you would to `child_process`.\n\n```js\nconst sh = await vm.spawn();                     \u002F\u002F a login shell on its own pty\nsh.output.pipeTo(new WritableStream({ write: (b) => process.stdout.write(b) }));\nawait sh.write(\"cat \u002Fetc\u002Falpine-release; exit\\n\");\nconsole.log(await sh.ended);                     \u002F\u002F { type: \"exit\", code: 0 }\n```\n\n`spawn(file, args, { cols, rows })` runs a program on a pty, in the\nzigpty \u002F node-pty shape, with `resize()`, `kill(signal)` and `close()` (a\nhangup). Run as many as you like. Keep reading `output`: the guest program\nwaits while nobody does.\n\n```js\nconst gz = await vm.spawn(\"gzip\", [\"-c\"], { pty: false });\ngz.stderr.cancel();                              \u002F\u002F read both outputs, or cancel one\nconst zipped = new Response(gz.stdout).bytes();\nawait new Response(\"hello\\n\").body.pipeTo(gz.stdin);   \u002F\u002F then EOF\nconsole.log((await zipped).length);\n```\n\nWith `pty: false` the program gets pipes: `stdin`, `stdout` and `stderr`\nweb streams, byte for byte.\n\n### Mount host files\n\n```js\nimport { createKernel, MemoryFs, nodeFs } from \"unkernel\";\n\nconst mem = new MemoryFs();\nmem.onChange((c) => console.log(c.type, c.path));   \u002F\u002F what the guest changed\n\nconst vm = await createKernel({\n  mounts: {\n    \"\u002Fmnt\u002Fhost\": { \"hello.txt\": \"hi\", dir: { \"a.bin\": bytes }, \"now.txt\": () => Date() },\n    \"\u002Fmnt\u002Fmem\": mem,\n  },\n});\nawait vm.exec(\"cp\", [\"\u002Fetc\u002Fos-release\", \"\u002Fmnt\u002Fmem\u002F\"]);\nconsole.log(mem.readText(\"\u002Fos-release\"));\n\nconst work = await vm.mount(\"\u002Fwork\", nodeFs(\".\"), { readOnly: true });   \u002F\u002F Node only\nawait work.unmount();\n```\n\nA file system is a plain object tree (a function is a computed file,\nevaluated once per open), a `MemoryFs` you read and write from the host,\n`nodeFs(dir)`, or your own `Fs`: `getattr`, `readdir` and `open` by path,\nsync or async, plus whichever change methods you want. Mounts are served\nover 9p on vsock. Each guest write reaches the host as it happens, and a\nhost change shows in the guest within a second.\n\n### Talk over vsock\n\n```js\nconst listener = vm.vsock.listen(5000);          \u002F\u002F guest programs connect to CID 2, port 5000\nvm.write(\"echo hello | kwvsock connect 5000\\n\");\nconst conn = await listener.accept();\nconsole.log(await new Response(conn.readable).text());   \u002F\u002F \"hello\\n\"\nconn.close();\n\nconst c = await vm.vsock.connect(6000);          \u002F\u002F a guest program listening on port 6000\nawait c.writable.getWriter().write(\"ping\");\n```\n\nThese are byte streams with real flow control and no network in between.\nvsock is on unless you pass `vsock: false`.\n\n```js\nconst sock = await vm.connect(8000);             \u002F\u002F TCP to the guest's 127.0.0.1:8000\nawait new Response(\"hello\\n\").body.pipeTo(sock.writable);   \u002F\u002F then EOF (a half-close)\nconsole.log(await new Response(sock.readable).text());\n```\n\n`vm.connect(port)` reaches a TCP server on the guest's loopback through\nthe guest's kwtty, over vsock, so it needs no network. It resolves once\nthe guest has connected (`PtyError` `ECONNREFUSED` if nothing listens) with\n`readable` and `writable` byte streams, half-close included, `close()` and\n`closed`. [The CLI's](#-run-it-from-the-terminal) `--forward\nHOSTPORT:GUESTPORT` uses it.\n\n`vm.fetch(url, init)` sends an HTTP\u002F1.1 request to a server in the guest\nand returns a `Response` whose body streams. It always connects to the\nguest's 127.0.0.1 at the URL's port; the host name only goes into the\n`Host` header, so `vm.fetch(\"http:\u002F\u002Flocalhost:8000\u002F\")` reaches a dev server\nlistening on port 8000. `fetchOver(connect, url, init)` is the same client\nover any byte stream.\n\n### Share memory\n\n```js\nconst vm = await createKernel({ shm: true });\nawait vm.exec(\"sh\", [\"-c\", \"printf result > \u002Fdev\u002Fshm\u002Foutput\"]);\n\nconst output = await vm.shm.open(\"output\");      \u002F\u002F a file a guest program made\nconst data = await output.read();\nconst views = output.views();                    \u002F\u002F zero-copy, until the kernel runs again\n\nconst input = await vm.shm.create(\"input\", 1 \u003C\u003C 20);   \u002F\u002F \u002Fdev\u002Fshm\u002Finput in the guest\nawait input.write(0, bytes);\n```\n\n`\u002Fdev\u002Fshm` exists once the guest's init has mounted it, so wait for the\nguest before `create()` (an `exec()` waits for it). `openId(id)` opens a\nmemfd that a guest program exported through `\u002Fdev\u002Fkwshm`. `views()`\nexists only when the kernel runs inline.\n\n### Display, input and sound\n\n```js\nimport { createKernel, domCodeToLinux, pcmToFloat32 } from \"unkernel\";\n\nconst vm = await createKernel({\n  display: { width: 800, height: 600 },          \u002F\u002F the guest gets \u002Fdev\u002Ffb0\n  onDisplay: (mode) => console.log(mode),        \u002F\u002F a program opened it (its mode) or closed it (null)\n  sound: { onChunk: ({ data, format }) => play(pcmToFloat32(data, format)) },\n});\n\nconst frame = vm.frame();                        \u002F\u002F RGBA, or null while nothing draws\nif (frame) ctx.putImageData(new ImageData(frame.data, frame.width, frame.height), 0, 0);\n\naddEventListener(\"keydown\", (e) => {\n  const key = domCodeToLinux(e.code);\n  if (key && vm.evdev.keyboardOpen) vm.evdev.key(key, true);\n});\n```\n\n`evdev` also has `button()`, `move()`, `moveTo()` and `wheel()` for a\nmouse or tablet. `onInput` tells you when a program opens the keyboard\nand mouse; until then, send keys to the console. `readFrame()` waits for\na fresh frame.\n\n### Run it in a worker\n\n```js\nconst vm = await createKernel({\n  worker: true,\n  net: { kind: \"net\", backend: { kind: \"direct\" } },\n  disks: [{ kind: \"file\", path: \"alpine.ext4\" }],\n});\n```\n\nThe kernel runs in a worker thread or Web Worker, with the same API. Disks\nand the network are given as specs, which the worker builds: `{ kind:\n\"file\", path }` on Node, `{ kind: \"http\", url }` and `{ kind: \"data\",\ntemplate: \"bundled\" }` in browsers. Input and frames go through shared\nmemory when it is available (`vm.transport` says). This mode is\nexperimental.\n\nAn SMP kernel (a bundle with the SMP patch) boots on several CPUs with\n`cpus: 4`, each CPU in a thread of its own on one shared memory. In\nbrowsers that needs a cross-origin isolated page and `worker: true`,\nbecause a CPU blocks while it waits for another, which a page's main\nthread may not; `webCpuBlocker()` says why it cannot, and\n`vm.stats().cpus` how many CPUs the kernel got.\n\n### Boot options and helpers\n\n```js\nimport { checkSupport, ConsoleRouter, createKernel } from \"unkernel\";\n\nconst support = await checkSupport();            \u002F\u002F JSPI and the rest, before you boot\nif (!support.ok) throw new Error(support.problems.join(\"\\n\"));\n\nconst vm = await createKernel({\n  kernel: \".\u002Fmy-kernel.wasm\",                    \u002F\u002F a URL, bytes, a Response or a WebAssembly.Module\n  initrd: \".\u002Finitramfs.cpio.gz\",                 \u002F\u002F null: none\n  cmdline: \"console=hvc0 rdinit=\u002Finit\",\n  memoryMiB: 1024,\n  jit: false,                                    \u002F\u002F interpreter only\n  onProgress: (p) => console.log(p.stage),\n});\n\nconst router = new ConsoleRouter({               \u002F\u002F kernel log lines apart from program output\n  onKernelLine: (line, { important }) => important && console.warn(line),\n  onUserOutput: (text) => process.stdout.write(text),\n});\nvm.onOutput((bytes) => router.write(bytes));\n```\n\nThe SDK has some limits, on top of the kernel's [known\nlimits](#-known-limits). There is no guest agent beyond terminal sessions, so\nyou drive the guest through a terminal or its console, or over vsock with your\nown program. `stop()` doesn't shut the guest down cleanly, so prefer\n`poweroff`. Only one kernel can run per thread. Types ship as `.d.mts` and use\nthe DOM's `WebAssembly` types, so a Node-only TypeScript project needs `\"lib\":\n[\"dom\"]` or `skipLibCheck`.\n\n## 🛠️ Building from source\n\nYou need Linux (x86-64 or arm64), Zig 0.16, Node 24, clang 21+ with the\nwasm target, and the usual build tools. `.\u002Fsetup.sh --check` lists what's\nmissing. The first build takes about 12 minutes, most of it spent on a\npatched `wasm-ld`, and uses 5 GiB of disk.\n\n```sh\n.\u002Fsetup.sh              # check, then build everything\nnode js\u002Fcli.ts          # boot your build\npnpm install && pnpm dev   # the web page at http:\u002F\u002Flocalhost:8080\nzig build test          # emulator tests\n```\n\n[kernel\u002FREADME.md](kernel\u002FREADME.md) covers the kernel, its devices and the\nguest image. [AGENTS.md](AGENTS.md) and [.agents\u002F](.agents\u002F) hold the\ncontributor notes: invariants, workflows, which tests to run, and the\n[roadmap](.agents\u002Fstatus.md).\n\n## 🙏 Credits\n\nMade with ♥ by [Pooya Parsa](https:\u002F\u002Fx.com\u002F_pi0_) ([pi0](https:\u002F\u002Fgithub.com\u002Fpi0)), sponsored by\n[▲ Vercel](https:\u002F\u002Fvercel.com\u002Fopen-source-program).\n\nThanks to:\n\n- [Kernarium](https:\u002F\u002Fgithub.com\u002Fimxieyi\u002FKernarium), for the idea: a native\n  kernel with emulated user space behind a software MMU.\n- [linux-wasm](https:\u002F\u002Fgithub.com\u002Fjoelseverin\u002Flinux-wasm) by Joel Severin,\n  for the `arch\u002Fwasm` port this kernel grew from, the wasm-ld linker-script\n  patches and the Kbuild toolchain wrapper.\n- [iSH](https:\u002F\u002Fgithub.com\u002Fish-app\u002Fish) and [v86](https:\u002F\u002Fgithub.com\u002Fcopy\u002Fv86),\n  for showing how to build a fast user-mode emulator and a wasm JIT.\n- [Alpine Linux](https:\u002F\u002Falpinelinux.org\u002F), [wterm](https:\u002F\u002Fwterm.dev\u002F),\n  [Binaryen](https:\u002F\u002Fgithub.com\u002FWebAssembly\u002Fbinaryen) and\n  [fx](https:\u002F\u002Ffx.sh\u002F) (the page's coding agent, libfx, Apache-2.0).\n\n## 📄 License\n\nEverything is open source: the kernel patches, the emulator and its JIT,\nthe patched linker, the SDK and the page. `.\u002Fsetup.sh` rebuilds the kernel\nfile from source.\n\nThe project is GPL-2.0-or-later ([LICENSE](LICENSE)) unless a file says\notherwise. The JavaScript SDK and page (`js\u002F`, `web\u002F`, SDK tests) are MIT\n([LICENSE-MIT](LICENSE-MIT)), so you can embed them anywhere.\n\nThe npm package ships a Linux kernel (GPL-2.0) with an Alpine userland whose\npackages keep their own licenses, so it is `MIT AND GPL-2.0-only`. The\nkernel's source is Linux 7.3.4 plus\n[kernel\u002Fpatches\u002Flinux](kernel\u002Fpatches\u002Flinux) (`arch\u002Fwasm` is based on\nlinux-wasm's). Those patches and\n`kernel\u002Ftools\u002Ffake-llvm` are GPL-2.0-only, and the patches in\n`kernel\u002Fpatches\u002Fllvm` follow LLVM's license (Apache-2.0 WITH\nLLVM-exception).\n","unkernel 是一个将真实 Linux 内核（Linux 7.x）完整编译为 WebAssembly 的项目，可在浏览器或 Node.js 中原生启动并运行标准 RISC-V64 Linux 用户程序。其核心特点是：内核代码（含 MMU、调度器、ext4、TCP\u002FIP 协议栈等）为直接编译的 WASM 模块，非模拟；用户态程序通过 JIT 动态翻译执行，支持未经修改的 Alpine\u002FUbuntu RISC-V64 二进制包。启动快（\u003C1 秒）、系统调用开销接近原生，适用于安全沙箱、Web 端 Linux 实验环境、教学演示及轻量级云原生开发测试等无需虚拟机或容器的隔离场景。",2,"2026-11-24 04:50:02","CREATED_QUERY"]