---
title: Disk
icon: hard-drive
description: Mount a directory on the host filesystem as a Mirage resource (Node only).
---

`DiskResource` mounts a directory on the host filesystem. Reads and writes go through `node:fs` against the configured `root`.

<Note>
  Node only. The browser SDK has no kernel filesystem; use [OPFS](/typescript/setup/opfs) instead.
</Note>

## Install

```bash
pnpm add @struktoai/mirage-node
```

## Config

```ts
import { DiskResource, MountMode, Workspace } from '@struktoai/mirage-node'

const disk = new DiskResource({ root: '/Users/me/data' })
const ws = new Workspace({ '/disk': disk }, { mode: MountMode.WRITE })

await ws.execute('echo hello | tee /disk/note.txt')
await ws.execute('cat /disk/note.txt')
```

| Field | Default | Notes |
| --- | --- | --- |
| `root` | required | Absolute path on the host. Reads and writes are scoped to this directory. |

## Mount mode

`read`, `write`, `exec`. Use `MountMode.EXEC` if you need commands to run binaries from the mount.

## Snapshot behavior

`DiskResource.toState()` captures the file tree as bytes. Loading a snapshot back doesn't re-create the directory; pass a config file with a fresh `root` if the original location changed.

For behavior shared with Python (filesystem layout, supported shell commands), see the [Python Disk docs](/python/resource/disk).
