Boot Options

Check support, pick a kernel and tune the boot.

import { checkSupport, createKernel } from "unkernel";

const support = await checkSupport(); // JSPI and the rest, before you boot
if (!support.ok) throw new Error(support.problems.join("\n"));

const vm = await createKernel({
  kernel: "./my-kernel.wasm", // a URL, bytes, a Response or a WebAssembly.Module
  initrd: "./initramfs.cpio.gz", // null: none
  cmdline: "console=hvc0 rdinit=/init",
  memoryMiB: 1024,
  jit: false, // interpreter only
  onProgress: (p) => console.log(p.stage),
});

createKernel() rejects with a BootError if the kernel cannot start.

#Limits

On top of the kernel's own limits:

  • There is no guest agent beyond terminal sessions, so you drive the guest through a terminal or its console, or over vsock with your own program.
  • stop() doesn't shut the guest down cleanly, so prefer poweroff.
  • Only one kernel can run per thread.
  • Types ship as .d.mts and use the DOM's WebAssembly types, so a Node-only TypeScript project needs "lib": ["dom"] or skipLibCheck.