Skip to content

memoryFS

memoryFS(): MemoryFileserver

Defined in: packages/core/src/kernel/fileservers/memory.ts:487

Create an in-memory fileserver with exec-node and freeze capabilities.

MemoryFileserver

A Fileserver with setExec, getExec, freeze, and SymlinkCapable methods.

The default backing store for a Unix system — holds /, /bin, /tmp, scratch files, and anything else a running process writes. Content lives on the JS heap of the boot that created it; it does NOT persist across reboots and is NOT shared between isolated Unix instances. Reach for overlayFS to stack a writable layer over a read-only base, or readonlyFS to deny mutations at a mount point.

The returned fileserver additionally implements ExecCapable | ExecCapable (setExec / getExec, used by coreutils and other presets to register bins as executables on /bin) and freeze() — once frozen, all mutations throw EPERM. This is how builder.build() produces an immutable image from a mutable construction-time fs.

import { memoryFS } from '@fishnet/core'
const fs = memoryFS()
await fs.mkdir('/etc')
const fd = await fs.open('/etc/motd', { write: true, create: true })
await fs.write(fd, 0, new TextEncoder().encode('hello\n'))
await fs.close(fd)
fs.freeze() // all further mutations throw EPERM

Process-local: nothing synchronizes state between two memoryFS() instances, even in the same tab. Share a reference if processes need to see each other’s writes.