![]() |
gmux 0.1.0
Linux on Cloudflare Workers
|
A real Linux kernel, compiled to WebAssembly, running inside one Cloudflare Worker. Each machine is a Durable Object with a BusyBox userland and a browser terminal.
Serverless platforms run functions, not machines. gmux runs the machine: Linux 7.3 boots to a shell inside a Durable Object, and ordinary Linux programs run on it unmodified, with processes, pipes, job control, signals, threads, sockets, fork and dlopen. A job that needs more CPU than one event allows continues across events. The host can turn a running machine into bytes (Machine.checkpoint) and resume it exactly in a fresh isolate (Machine.restore).
Run a machine locally with Docker:
Open http://localhost:8787/_gmux/term, claim the machine, and you are at a root shell. The container's /var/lib/gmux volume holds the machine's Durable Object storage.
Deploy your own to Cloudflare:
The first visitor to /_gmux/term claims the machine and receives its owner token.
The machine host is an npm package with the kernel, BusyBox, Katybug and the initramfs inside it:
The host runs in a Durable Object, workerd, or Node with JSPI (WebAssembly.Suspending). In a Worker, .wasm imports compile at deploy time, which is the only place a Worker may compile code.
| Userland | BusyBox, with an interactive shell, pipelines and job control |
| Processes | fork, vfork, execve, pthreads, signals with handlers that block |
| System | sockets (Unix and loopback TCP), epoll, eventfd, timerfd, inotify, flock, System V IPC |
| Libraries | dlopen of wasm side modules shipped with the deployment |
| Foreign binaries | unchanged x86-64 and AArch64 Linux ELFs, through Katybug |
Programs are compiled for wasm32-linux with scripts/cc-strict, which refuses any import outside the syscall surface. Code that arrives at run time cannot be compiled on Workers, so every native executable is built with the deployment.
Katybug runs unmodified x86-64 and AArch64 Linux executables inside a machine. It ships in the package as kernel/katybug.wasm, an ordinary gmux program: it decodes the guest's machine code into gmux's IR, runs it, and turns each guest syscall into the machine's own. The init script registers it with binfmt_misc, so a shell, execve and fork treat a foreign ELF like any other program.
Register Katybug next to BusyBox, then add the executable to the root filesystem by appending a newc cpio archive to the initramfs. The kernel unpacks the archives in order.
digest is optional. With it, a digest stream Katybug recognizes runs on the host's crypto; without it, Katybug hashes with its own kernels. A machine cannot checkpoint while a host digest is open.
The technical report's Foreign Executables section covers how Katybug decodes, caches and lifts code, its host kernels, and what each costs.
The kernel and every process share one WebAssembly memory. A syscall is a direct call from the program's instance into the kernel's. Blocking is JSPI: every task that waits is a suspended wasm stack, and one pump on the Durable Object's single thread resumes exactly the task the kernel schedules next. When a machine has to leave memory, its parked stacks become bytes (Asyncify for the kernel, resumable frames or Asyncify for programs), and a restore rewinds them into fresh instances. Foreign executables run through Katybug.
TECHNICAL_REPORT.md has the design, the platform limits that shape it, and what each operation costs.
A machine is a Durable Object: code inside it has no Worker bindings, secrets or network authority beyond what the host passes to it, and a deployed Worker cannot compile code at run time. Inside one machine, root processes share one trust domain; a non-root process reaches only its own memory and the shared mappings it maps, and a forked process runs in a memory of its own. SECURITY.md has the trust model, the import surface and the threat matrix.
The kernel, musl, BusyBox and Katybug build reproducibly on a Linux host with Docker from the pins in src/sources.json and the patches under src/:
Two clean builds produce the same bytes in every artifact. The probes refuse a build/kernel staged from other pins or patches than the tree's.
The kernel, LLVM and linux-wasm forks are fetched from mirrors listed in src/mirrors.json, so a build does not depend on their authors keeping them online. bun scripts/sync-mirrors.ts reports new and moved branches and checks that every pinned commit is on its mirror; --apply copies the new and moved branches to the mirrors with a gh login that can write to them.
gmux is GPL-3.0-only. The kernel and its patches are GPL-2.0-only (LICENSES/), BusyBox is GPL-2.0-only, musl is MIT, and zlib, built into Katybug, is under the zlib licence (LICENSES/Zlib.txt).