> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Disk

> Virtualize a directory on the host as workspace files.

![](https://mintcdn.com/struktoai/F9Lv_nTaj6By6crk/images/python-logo.svg?fit=max\&auto=format\&n=F9Lv_nTaj6By6crk\&q=85\&s=cf5b268d330f7db46ea5cf6083f309a1)

Node.js

Disk mounts a host directory at a workspace path. Its files and folders show
up as they are on disk.

## Connect

> [tab] YAML
>
> ```yaml workspace.yaml theme={null}
> mounts:
>   /data:
>     vfs: disk
>     mode: read
>     config:
>       root: /srv/files
> ```
>
> ```bash theme={null}
> mirage workspace create workspace.yaml --id files
> mirage shell -w files -c 'ls /data'
> ```

> [tab] Python
>
> ```python theme={null}
> from mirage import MountMode, Workspace
> from mirage.vfs.disk import DiskVFS
>
> ws = Workspace({"/data": DiskVFS(root="/srv/files")}, mode=MountMode.READ)
> result = await ws.shell("ls /data")
> print(await result.stdout_str())
> await ws.close()
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { DiskVFS, MountMode, Workspace } from '@struktoai/mirage-node'
>
> const ws = new Workspace(
>   { '/data': new DiskVFS({ root: '/srv/files' }) },
>   { mode: MountMode.READ },
> )
> const result = await ws.shell('ls /data')
> console.log(result.stdoutText)
> await ws.close()
> ```

## Layout

```text theme={null}
/data/
  config.json
  notes.md
  reports/
    q1.csv
    q2.csv
```

* The mount mirrors `root`; a path such as `../../etc/passwd` never leaves it.
* A second disk mount whose `root` resolves to a folder already mounted is
  refused; a folder inside one is fine.
* Python and Node only. In a browser, use [OPFS](https://docs.mirage.strukto.ai/home/setup/opfs.md).

## Sample runs

```bash theme={null}
$ tree /data
/data
|-- config.json
|-- notes.md
`-- reports
    |-- q1.csv
    `-- q2.csv

2 directories, 4 files
```

```bash theme={null}
$ grep -r west /data/reports
/data/reports/q1.csv:west,120
/data/reports/q2.csv:west,140
```

```bash theme={null}
$ jq -r .region /data/config.json
us-east-1
```

Set `mode: write` to let commands change the directory's files. Add
`capacity: 1GB` under `config` to cap the bytes it holds; see
[capacity](https://docs.mirage.strukto.ai/home/setup/vfs.md#mount-capacity).

## SDK guides

> [card] [Python](https://docs.mirage.strukto.ai/python/vfs/disk.md)
>
> Every config field, the VFS.md and write support.

> [card] [TypeScript](https://docs.mirage.strukto.ai/typescript/vfs/disk.md)
>
> Every config field, the VFS.md and write support.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.