# Shared Filesystems (SFS) — Mount persistent, unified storage across multiple sandboxes.

> This article is part of the [Render Sandboxes documentation bundle](https://render.com/docs/sandboxes/all). Fetch the bundle for all related articles in one Markdown document.

> For the complete documentation index, see [llms.txt](https://render.com/llms.txt).


> *Shared filesystems are in private alpha. They currently only support sandboxes.*
>
> During the alpha period:
>
> - Avoid using shared filesystems for mission-critical workloads.
> - All limits and APIs are subject to change.

You can mount a *shared filesystem* (*SFS*) to multiple Render Sandboxes so they can read and write to the same persistent storage:

```mermaid
flowchart LR
  subgraph "<b>Oregon region</b>"
    direction LR
    sandboxA["Sandbox A"] edge1@-->|"<code>/var/disk</code>"| filesystem
    sandboxB["Sandbox B"] edge2@-->|"<code>/var/data</code>"| filesystem
    sandboxC["Sandbox C"] edge3@-->|"<code>/var/disk</code>"| filesystem
    filesystem[["<b>SFS</b>"]]
    class filesystem success;
    edge1@{animation: slow}
    edge2@{animation: slow}
    edge3@{animation: slow}
  end
```

Whenever a sandbox makes changes to an SFS, those changes are reflected across all _other_ mounting sandboxes in near real-time.

*Shared filesystems are ideal for multi-agent collaboration.* They persist beyond the lifetime of any individual sandbox. Under the hood, each SFS is backed by Render-managed volumes in the same region as the sandboxes that mount it.

- Shared filesystems are compatible with most tools like Git and SQLite that use file-based locks to coordinate concurrent access.
  - Mechanisms that require sharing memory across clients (such as SQLite's WAL mode) are not supported and might result in data corruption.
- For custom tooling, you can coordinate concurrent access with the `flock` utility. [See details below.](<https://render.com/docs/shared-filesystems.md#handling-concurrent-operations>)

## Setup

After your workspace is added to the shared filesystems private alpha, you can start creating shared filesystems with the following steps.

### 1. Install the Render CLI or SDK

You can create shared filesystems using the Render CLI or SDK.

**Tab: CLI**

Shared filesystems require Render CLI version *2.41.0 or later*.

Use any of the following methods to install the Render CLI or upgrade to the latest version:

**Subtab: Homebrew**

##### Homebrew installation

Run the following commands:

```shell
brew update
brew install render
```

**Subtab: WinGet**

##### WinGet installation

Run the following command:

```shell
winget install render.cli
```

**Subtab: curl**

##### Installing with `curl`

Run the following command:

```shell
curl -fsSL https://raw.githubusercontent.com/render-oss/cli/refs/heads/main/bin/install.sh | sh
```

**Subtab: Direct download**

##### Direct download

1. Open the CLI's [GitHub releases page](https://github.com/render-oss/cli/releases/).
2. Download the executable that corresponds to your system's architecture.

If you use an architecture besides those provided, you can build from source instead.

**Subtab: Build from source**

##### Building from source

> We recommend building from source only if no other installation method works for your system.

1. [Install the Go programming language](https://golang.org/doc/install) if you haven't already.

2. Clone and build the CLI project with the following commands:

   ```shell
   git clone git@github.com:render-oss/cli.git
   cd cli
   go build -o render
   ```

After installation completes, open a new terminal tab and run `render` with no arguments to confirm.

**Tab: TypeScript**

From your TypeScript project directory:

```shell
npm install @renderinc/sdk@latest
```

(Or `pnpm install`, `bun add`, etc.)

*If you already have the SDK installed,* make sure you're using version `1.13.0` or later:

```shell
npm install @renderinc/sdk@latest
```

After installing, make sure `@renderinc/sdk` is listed as a dependency in your `package.json` file at version `^1.13.0` or later.

**Tab: Python**

From your Python project directory:

```shell
pip install render
```

*If you already have the SDK installed,* make sure you're using version `1.13.0` or later:

```shell
pip install --upgrade render
```

After installing, make sure to add `render>=1.13.0` as a dependency in your application's `requirements.txt`, `pyproject.toml`, or equivalent.

### 2. Create an API key

1. Expand the steps below to create a Render API key with at least the following permissions:

    | Permission | Level | Purpose |
    | --- | --- | --- |
    | *Shared filesystems* | Read & write | Enables creating shared filesystems. Enables mounting a shared filesystem in a new sandbox. |
    | *Sandbox lifecycle and snapshots* | Read & write | Enables sandbox creation. |
    | *Sandbox execution and file transfer* | Execute | Enables command execution within a sandbox. |

1. Go to your [Account Settings page](https://dashboard.render.com/u/settings?add-api-key) in the Render Dashboard and click *Create API key*.

       [image: The API Keys page in the Render Dashboard]

    2. Give your key a name.
    3. Select the workspace your key can access.
    4. Grant your key permissions. For details, see [Permissions](<https://render.com/docs/api-keys.md#permissions>).
       - You can also set permissions for _all workspace resources_ at once:

         [image: Buttons to change the permissions for all resource types at once in the API key creation form]

         - *All:* Grants every permission your member role allows for every resource.
         - *Read only:* Grants *Read* access to every applicable resource.
         - *Clear all:* Removes all permissions from the key.

    5. Click *Generate API key*. Your key is shown in full only once:

       [image: The API key created dialog showing the new key with a button to copy it]

> *API keys are secret credentials!*
>
>     Don't publicly post your API key, commit it to version control, or otherwise share it with anyone outside your organization. If you believe an API key has been compromised, [revoke it](/api-keys#revoke-an-api-key).

    ### 2. Make your first request

    To test your key, call a Render API endpoint it has permission to access.

    For example, a key with *Read* access to [services](/api-keys#services) can call the [List services](https://api-docs.render.com/reference/list-services) endpoint. Replace `{API_KEY}` with your key and run the following:

    ```bash
    curl --request GET \
         --url 'https://api.render.com/v1/services?limit=20' \
         --header 'Accept: application/json' \
         --header 'Authorization: Bearer {API_KEY}'
    ```

    If your API key is valid, the request returns a `200` response and an array of services.

2. Configure your API key and workspace ID for your chosen tool (CLI or SDK), as described in [this section](<https://render.com/docs/sandboxes.md#2-set-up-credentials>).

### 3. Create a shared filesystem

You can create a shared filesystem in either of the following ways:

| Method | Description |
| --- | --- |
| *Standalone* | Create an SFS without mounting it to any sandboxes. See [Standalone creation](<https://render.com/docs/shared-filesystems.md#standalone-creation>) below. |
| *With a sandbox* | Create an SFS _while_ creating the first sandbox that mounts it. Proceed directly to [4. Mount the SFS in a new sandbox](<https://render.com/docs/shared-filesystems.md#4-mount-the-sfs-in-a-new-sandbox>). |

#### Standalone creation

The following example creates an SFS named `agent-data` in your workspace:

**Tab: CLI**

> Requires Render CLI version 2.41.0 or later.

```shell
render sfs create --name agent-data
```

**Tab: TypeScript**

> Requires SDK version 1.13.0 or later.

```typescript
import { Render } from '@renderinc/sdk'

const sharedFilesystems = new Render().sharedFilesystems
await sharedFilesystems.create({ name: 'agent-data' })
```

**Tab: Python (sync)**

> Requires SDK version 1.13.0 or later.

```python
from render import Render

shared_filesystems = Render().shared_filesystems
shared_filesystems.create("agent-data")
```

**Tab: Python (async)**

> Requires SDK version 1.13.0 or later.

```python
import asyncio
from render import RenderAsync

async def main():
    shared_filesystems = RenderAsync().shared_filesystems
    await shared_filesystems.create("agent-data")

asyncio.run(main())
```

After creating the SFS, you can [mount it in multiple sandboxes](<https://render.com/docs/shared-filesystems.md#4-mount-the-sfs-in-a-new-sandbox>).

### 4. Mount the SFS in a new sandbox

When creating a sandbox, you can provide a name and an absolute mount path for a shared filesystem. *If no SFS with the provided name exists in your workspace, Render creates it.*

The following example mounts an SFS named `agent-data` at path `/data`:

**Tab: CLI**

```shell
render sandboxes create --shared-filesystem agent-data:/data --wait
```

**Tab: TypeScript**

```typescript
import { Render } from '@renderinc/sdk'

const sandboxes = new Render().sandboxes

const sandbox = await sandboxes.create({
  sharedFilesystems: [{ name: 'agent-data', mountPath: '/data' }],
  wait: true
})

console.log(sandbox.id)
```

**Tab: Python (sync)**

```python
from render import Render
from render.sandbox import SharedFilesystemMount

sandboxes = Render().sandboxes

sandbox = sandboxes.create(
    shared_filesystems=[SharedFilesystemMount(name="agent-data", mount_path="/data")],
    wait=True,
)

print(sandbox.id)
```

**Tab: Python (async)**

```python
import asyncio
from render import RenderAsync
from render.sandbox import SharedFilesystemMount

async def main():
    sandboxes = RenderAsync().sandboxes

    sandbox = await sandboxes.create(
        shared_filesystems=[SharedFilesystemMount(name="agent-data", mount_path="/data")],
        wait=True,
    )

    print(sandbox.id)

asyncio.run(main())
```

- Any number of sandboxes can mount the same SFS.
- It is not currently possible to mount an SFS to an already running sandbox (only during creation).
- Each sandbox can currently mount a maximum of one SFS.

### 5. Write to the SFS

After a sandbox finishes spinning up, you can start [executing commands](<https://render.com/docs/sandboxes-executing.md>) that read and write to the shared filesystem. The following example creates a file under `/data` (the mount path provided in the previous step) and reads it back.

Replace `sbx-abc123` with the ID returned when you created the sandbox in [step 4](<https://render.com/docs/shared-filesystems.md#4-mount-the-sfs-in-a-new-sandbox>).

**Tab: CLI**

```shell
render sandboxes exec sbx-abc123 -- sh -c \
  'echo "Hello, world!" > /data/hello.txt && cat /data/hello.txt'
```

**Tab: TypeScript**

```typescript
import { Render } from '@renderinc/sdk'

const sandboxes = new Render().sandboxes
const sandboxId = 'sbx-abc123'
const command = 'echo "Hello, world!" > /data/hello.txt && cat /data/hello.txt'

const events = await sandboxes.exec(sandboxId, command)

for await (const event of events) {
  if (event.type === 'output') {
    const stream = event.stream === 'stderr' ? process.stderr : process.stdout
    stream.write(event.data)
  } else if (event.type === 'exit' && event.exit_code !== 0) {
    throw new Error(`Command failed with exit code ${event.exit_code}`)
  }
}
```

**Tab: Python (sync)**

```python
import sys
from render import Render
from render.sandbox import SandboxExecExit, SandboxExecOutput

sandboxes = Render().sandboxes
sandbox_id = "sbx-abc123"
command = 'echo "Hello, world!" > /data/hello.txt && cat /data/hello.txt'

for event in sandboxes.exec(sandbox_id, command):
    if isinstance(event, SandboxExecOutput):
        stream = sys.stderr if event.stream == "stderr" else sys.stdout
        print(event.data, end="", file=stream, flush=True)
    elif isinstance(event, SandboxExecExit) and event.exit_code != 0:
        raise RuntimeError(f"Command failed with exit code {event.exit_code}")
```

**Tab: Python (async)**

```python
import asyncio
import sys
from render import RenderAsync
from render.sandbox import SandboxExecExit, SandboxExecOutput

async def main():
    sandboxes = RenderAsync().sandboxes
    sandbox_id = "sbx-abc123"
    command = 'echo "Hello, world!" > /data/hello.txt && cat /data/hello.txt'

    async for event in sandboxes.exec(sandbox_id, command):
        if isinstance(event, SandboxExecOutput):
            stream = sys.stderr if event.stream == "stderr" else sys.stdout
            print(event.data, end="", file=stream, flush=True)
        elif isinstance(event, SandboxExecExit) and event.exit_code != 0:
            raise RuntimeError(f"Command failed with exit code {event.exit_code}")

asyncio.run(main())
```

## Handling concurrent operations

A shared filesystem doesn't automatically lock files when a sandbox reads or writes them. Without coordination, writes from one sandbox might immediately overwrite writes from another:

```mermaid
sequenceDiagram
  participant A as Sandbox A
  participant FS@{ "type" : "collections" } as SFS
  participant B as Sandbox B

  Note over FS: <code>notes.txt</code><br>is empty
  A->>FS: Writes <code>hello</code> to<br><code>notes.txt</code>
  Note over FS: <code>notes.txt</code><br>contains <code>hello</code>
  B->>FS: Writes <code>world</code> to<br><code>notes.txt</code>
  Note over FS: <code>notes.txt</code><br>contains <code>world</code>
```

> *Concurrently appending to the same SFS file from different sandboxes might result in data loss or corruption.*
>
> This is true even if all writers open the file with [`O_APPEND`](https://man7.org/linux/man-pages/man2/open.2.html#DESCRIPTION).
>
> To append safely, do one of the following:
>
> - Use a single writer per file.
> - Require every writer to hold an [exclusive lock on the same lockfile](<https://render.com/docs/shared-filesystems.md#coordinating-access-with-flock>) while appending.

Popular tools like Git and SQLite use file-based locks to coordinate concurrent access. Git uses lockfiles to coordinate updates, and SQLite uses file locks in its default rollback journal mode. These locks can coordinate access across sandboxes that mount the same SFS, without any additional configuration.

SQLite’s [WAL mode](https://www.sqlite.org/wal.html) requires shared memory across clients. Because sandboxes do _not_ share a memory space, this mode is not supported and might result in data corruption. The same is true for other mechanisms that rely on shared memory.

### Coordinating access with `flock`

If you're writing custom code that handles its own locking, you can use the Linux `flock` utility to coordinate reads and writes across sandboxes. Have each sandbox acquire an advisory lock on the same lockfile before it reads or updates a set of related files. This helps prevent a reader from seeing a partially completed update.

```mermaid
sequenceDiagram
  participant A as Sandbox A<br>(writer)
  participant FS@{ "type" : "collections" } as SFS
  participant B as Sandbox B<br>(reader)

  A->>FS: Requests <b>exclusive</b> lock on<br><code>update.lock</code>
  FS-->>A: Lock acquired
  Note over A,FS: Starts updating files
  B->>FS: Requests <b>shared</b> lock on<br><code>update.lock</code><br>and waits
  Note over A,FS: Finishes updating files
  A-->>FS: Lock released
  FS-->>B: Lock acquired
  Note over FS,B: Starts reading files
```

> *Important considerations:*
>
> - *Always write lockfiles to the same SFS as the files they lock.*
>
>     If you write a lockfile to a sandbox's local filesystem, it's invisible to all other sandboxes, preventing them from coordinating.
>
> - *Advisory locks only coordinate clients that honor them.*
>
>     Your sandboxes must all coordinate their operations through the same set of lockfiles. A sandbox that skips the appropriate locks might read or write files while another sandbox's update is in progress.
>
> - *Keep lockfiles in place while any sandbox might be using them.*
>
>     Deleting or replacing a lockfile might result in two sandboxes acquiring locks on different files at the same path.

## Interactions with sandbox snapshots

You can capture [snapshots](<https://render.com/docs/sandboxes-snapshots.md>) of a sandbox to preserve its local filesystem, along with its memory and CPU state. When using both shared filesystems _and_ snapshots with a given sandbox, note the following:

- Neither [kind of snapshot](<https://render.com/docs/sandboxes-snapshots.md#kinds-of-snapshots>) includes the sandbox's shared filesystem, if it mounts one.
- Whenever you restore a sandbox from a [runtime snapshot](<https://render.com/docs/sandboxes-snapshots.md#kinds-of-snapshots>):
  - The new sandbox _must_ mount the exact same shared filesystem at the exact same mount path as the source sandbox, if it mounted any.
  - The new sandbox _may_ mount a shared filesystem as desired, if the source sandbox did _not_ mount one.
- Mounting a shared filesystem when restoring from a snapshot does not revert the filesystem to its state at the time of the snapshot.

## Storage limits

All SFS limits are subject to change during the alpha period:

| Item | Limit |
| --- | --- |
| *Max storage per SFS* | 100 GB |
| *Max SFS storage per workspace* | 200 GB (combined across all SFS in a workspace) |

## Pricing

Shared filesystems are not billed during the private alpha period.

Full pricing details will be published prior to the start of the first active billing period for shared filesystems.

## Alpha limitations

We plan to address these known limitations of shared filesystems following the alpha period:

- Shared filesystems are only available in the Oregon region.
    - This is also currently true for sandboxes.
- Render service types besides sandboxes cannot mount an SFS.
- You cannot mount an SFS to an already running sandbox (only during creation).
- Each sandbox can mount a maximum of one SFS.
- It is not possible to delete an SFS.

## FAQ

###### Can sandboxes in different sandbox groups mount the same SFS?

Yes. A sandbox can mount an SFS as long as it's in the same region _and_ belongs to the same workspace.

###### What happens if I mount an SFS over an existing local directory?

If an SFS path collides with an existing directory on a sandbox's local filesystem, all file operations in the sandbox see the SFS contents at that path.

*Files in the local filesystem _are_ preserved.* Any [snapshots](<https://render.com/docs/sandboxes-snapshots.md>) captured of the sandbox include local filesystem files hidden beneath the mount.

###### Do shared filesystems support file-change notifications?

Not fully. If a particular sandbox uses `inotify` to monitor a shared file, it receives notifications only for changes made by processes _in that sandbox_. SFS changes made by other sandboxes do not trigger notifications.

###### How can I back up SFS data?

Mount the SFS in a sandbox, then [execute commands in the sandbox](<https://render.com/docs/sandboxes-executing.md>) to copy SFS files to separate storage.

Note that [sandbox snapshots](<https://render.com/docs/shared-filesystems.md#interactions-with-sandbox-snapshots>) exclude SFS data.


---

##### Appendix: Glossary definitions

###### Render Sandboxes

Create a sandbox to execute untrusted code in a managed, ephemeral environment.

Ideal for agents, code interpreters, builds, tests, and other workloads that require isolated execution.

Related article: https://render.com/docs/sandboxes.md

###### region

Each Render service runs in one of the following regions: *Oregon*, *Ohio*, *Virginia*, *Frankfurt*, or *Singapore*.

Services in the same region can communicate over their *private network*.

Related article: https://render.com/docs/regions.md