mirror of
https://github.com/pithings/unkernel.git
synced 2026-12-06 08:59:57 +08:00
1.1 KiB
1.1 KiB
icon
| icon |
|---|
| ph:sliders-horizontal-duotone |
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 preferpoweroff.- Only one kernel can run per thread.
- Types ship as
.d.mtsand use the DOM'sWebAssemblytypes, so a Node-only TypeScript project needs"lib": ["dom"]orskipLibCheck.