---
title: Drives
description: Mount Vercel Drives into sandboxes for persistent storage that survives stops and is shared across runs.
url: "https://vercel.com/docs/sandbox/concepts/drives"
last_updated: 2026-09-21
related:
  - /docs/drives
  - /docs/sandbox/concepts/snapshots
  - /docs/drives/pricing
  - /docs/sandbox/concepts/images
  - /docs/sandbox/pricing
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# Drives

Drives provide persistent storage that you mount into a sandbox as a working directory. Your agent can generate code, download dependencies, and build up context in that directory, keeping its progress across sessions.

Files written to a drive persist after the sandbox stops. Mount the same drive in a later run to pick up where you left off, even when starting from a different sandbox environment. You can mount up to four drives in a sandbox, each at its own path alongside the sandbox's own filesystem.

To learn how to create and manage drives, see [Vercel Drives](/docs/drives). This page covers how to mount drives into sandboxes and how they compare to sandbox snapshots.

You currently need to mount a drive into a sandbox to read and write files using the sandbox's drive mount path.

## When to use drives vs snapshots

A sandbox is a computer, and a [sandbox snapshot](/docs/sandbox/concepts/snapshots) is a saved copy of that computer, including its filesystem, installed tools, and packages. Start a new sandbox from a sandbox snapshot and it boots with everything already set up.

A [drive](/docs/sandbox/concepts/drives) is a disk you attach to that computer. It holds your files outside the sandbox, so the files outlive the sandbox. One sandbox writes to a drive at a time, and many sandboxes can read the same files at once through [drive snapshots](/docs/sandbox/concepts/drives#snapshots), which are point-in-time saves of the drive's files.

Use both together. Start from a sandbox snapshot for the environment, and mount a drive for the files you work on.

For most state you want to keep, use a drive:

- **It outlives the sandbox**: Files on a drive stay until you delete the drive. A sandbox snapshot [expires 30 days after its last use by default](/docs/sandbox/concepts/snapshots#snapshot-retention).
- **It's shared**: Sandboxes that mount a drive work with the same files. Sandboxes started from a sandbox snapshot each get their own copy, and their changes aren't shared.
- **It holds more**: A drive [defaults to 1 TiB, or 1 GiB on Hobby](/docs/drives/pricing#limits). A sandbox filesystem is 64 GB.
- **It has versions**: Checkpoint a drive with a [named drive snapshot](/docs/sandbox/concepts/drives#create-and-mount-a-named-snapshot) before you change it. Later, mount that version in other sandboxes, or fork it into a new drive that starts from that version. See [Example: versioning a drive](/docs/sandbox/concepts/drives#example:-versioning-a-drive).
- **It keeps sandboxes quick to start**: Moving working files to a drive keeps the sandbox snapshot small.

Keep the starting environment lean. Use a [custom image](/docs/sandbox/concepts/images#custom-images) for stable setup that many sandboxes need, such as OS packages, language runtimes, package managers, agents, and common tools. Use sandbox snapshots for reusable runtime state that should be ready at startup.

Put heavy working state on drives. Cloned repositories, generated files, datasets, build output, dependency caches, logs, and agent workspace state usually belong on a drive. A drive mounts as a directory in the sandbox, and the sandbox reads and writes those files through the mount path as the workload needs them.

If a sandbox snapshot is large and rarely reused, move stable setup into a custom image and move changing project data into a drive. This keeps the boot path smaller and helps the sandbox start faster.

The following table compares a drive with a sandbox snapshot in detail:

| Aspect                 | Drive                                                                                                    | Sandbox snapshot                                                             |
| ---------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Storage type           | Single directory mounted on a sandbox                                                                    | Full sandbox filesystem                                                      |
| Sharing                | Shared storage across sandboxes                                                                          | Independent copy per sandbox, changes are not shared                         |
| Read/write access      | One read-write mount, many read-only mounts via drive snapshots                                          | Read-write filesystem for each sandbox                                       |
| Read/Write performance | NVMe speed writes and cache hit reads, slower cache miss reads                                           | NVMe speed reads and writes                                                  |
| Storage size           | 1 TiB by default (1 GiB for Hobby). 16 TiB maximum quota, higher by request                              | 64 GB (filesystem size)                                                      |
| Expiration             | Persists until manually deleted                                                                          | Expires after 30 days by default, can be extended to infinity                |
| Use cases              | Working files, cloned repositories, generated output, datasets, dependency caches, agent workspace state | Reusable startup environments, installed tools, small filesystem checkpoints |
| Price                  | [Regional storage, reads, and writes](/docs/drives/pricing)                                              | [Storage per GB-month](/docs/sandbox/pricing#snapshot-storage)               |

## Common patterns

- Agent workspace: store an agent workspace that persists across sandbox runs, building context over time. [Give each user of an eve agent a workspace drive](/kb/guide/vercel-drives-eve-agent) so files persist across that user's sessions.
- Shared cache: cache dependencies, build artifacts, or other large data.
- Pre-seeding data: pre-seed a drive with data, then spin up compute on demand when needed. [Share datasets across analysis sandboxes](/kb/guide/large-scale-data-analysis-vercel-sandbox-mcp#how-to-share-large-datasets-across-sandboxes-with-vercel-drives) by loading a dataset once and mounting read-only drive snapshots in separate query sandboxes.
- Versioning: save a named drive snapshot before you change a drive, so you can mount that version later or fork it into a new drive that starts from that version. See [Example: versioning a drive](#example:-versioning-a-drive).

### Example: a shared dependency cache

You run an agent that installs the same 10 GB of dependencies on every sandbox. With a sandbox snapshot, each sandbox gets its own copy, reinstalling and storing them separately every time. With a drive, they all read from one shared copy that persists across runs.

**index.ts**

```ts filename="index.ts"
import { Drive } from '@vercel/drives';
import { Sandbox } from '@vercel/sandbox';

const cache = await Drive.getOrCreate({ name: 'shared-deps' });

// One sandbox populates the cache (single read-write mount)
const writer = await Sandbox.create({
  region: cache.region,
  source: {
    type: 'git',
    url: 'https://github.com/vercel/ms.git',
    depth: 1,
  },
  mounts: { '/cache': cache },
});
await writer.runCommand({
  cmd: 'pnpm',
  args: ['install', '--store-dir', '/cache'],
});
await writer.stop();

// Later sandboxes read the same cache without reinstalling
const sandbox = await Sandbox.create({
  region: cache.region,
  mounts: { '/cache': cache.snapshot() },
});
```

**main.py**

```py filename="main.py"
import asyncio

from vercel import drives, sandbox
from vercel.sandbox import GitSource

async def main() -> None:
    cache, created = await drives.get_or_create_drive(name="shared-deps")

    # One sandbox populates the cache (single read-write mount)
    writer = await sandbox.create_sandbox(
        region=cache.region,
        source=GitSource(
            url="https://github.com/vercel/ms.git",
            depth=1,
        ),
        mounts={"/cache": cache},
    )
    await writer.run_command("pnpm", ["install", "--store-dir", "/cache"], check=True)
    await writer.stop()

    # Later sandboxes read the same cache without reinstalling
    reader = await sandbox.create_sandbox(
        region=cache.region,
        mounts={"/cache": cache.snapshot()},
    )

asyncio.run(main())
```

### Example: versioning a drive

You keep a dataset on a drive, and an agent rewrites it on every run. Save a named drive snapshot before each run to keep the previous version. Later writes to the drive don't change the named drive snapshot, so other sandboxes can keep reading that version. If a run goes wrong, fork the named drive snapshot into a new drive that starts from that version. The original drive keeps its newer files.

A named drive snapshot contains only the data the drive has already saved, so stop the sandbox that writes to the drive before you create one. Vercel bills each named drive snapshot as [drive storage](/docs/drives/pricing#drive-storage) until you delete it, so [delete the versions](/docs/drives/cli-reference#vercel-drives-snapshots-delete) you no longer need.

1. Save the `dataset` drive as the named drive snapshot `v1`. The drive and `v1` both hold version 1.
2. Mount the drive read-write and write version 2. The drive now holds version 2, and `v1` still holds version 1.
3. Mount `v1` in a reader sandbox. The reader sees version 1, read-only.
4. Fork `v1` into the new drive `dataset-rollback`. The new drive starts at version 1, and `dataset` keeps version 2.

This example assumes the `dataset` drive already holds version 1 and no sandbox has the drive mounted read-write:

**index.ts**

```ts filename="index.ts"
import { Drive } from '@vercel/drives';
import { Sandbox } from '@vercel/sandbox';

const drive = await Drive.get({ name: 'dataset' });

// 1. Checkpoint the drive before the next run
const v1 = await drive.snapshot({ name: 'v1' });

// 2. The writer changes the drive
const writer = await Sandbox.create({
  region: drive.region,
  mounts: { '/data': drive },
});
await writer.runCommand({
  cmd: 'sh',
  args: ['-c', 'echo "version 2" > /data/version.txt'],
});
await writer.stop();

// 3. A reader still sees the files as they were at v1
const reader = await Sandbox.create({
  region: v1.region,
  mounts: { '/data': v1 },
});

// 4. Go back to v1 in a new writable drive
const rollback = await v1.fork({ name: 'dataset-rollback' });
```

**main.py**

```py filename="main.py"
import asyncio

from vercel import drives, sandbox

async def main() -> None:
    drive = await drives.get_drive(name_or_id="dataset")

    # 1. Checkpoint the drive before the next run
    v1 = await drive.create_snapshot(name="v1")

    # 2. The writer changes the drive
    writer = await sandbox.create_sandbox(
        region=drive.region,
        mounts={"/data": drive},
    )
    await writer.run_command(
        "sh", ["-c", 'echo "version 2" > /data/version.txt'], check=True
    )
    await writer.stop()

    # 3. A reader still sees the files as they were at v1
    reader = await sandbox.create_sandbox(
        region=v1.region,
        mounts={"/data": v1},
    )

    # 4. Go back to v1 in a new writable drive
    rollback = await v1.fork(name="dataset-rollback")

asyncio.run(main())
```

**terminal.sh**

```bash filename="terminal.sh"
# 1. Checkpoint the drive before the next run
vercel drives snapshot dataset v1

# 3. A reader still sees the files as they were at v1
sandbox create --name reader --region iad1 --mount dataset:/data:snapshot:v1

# 4. Go back to v1 in a new writable drive
vercel drives snapshots fork v1 dataset-rollback --drive dataset
```

### Mounting a drive

Mount a drive by passing the drive name and mount path when creating a sandbox. The sandbox's main [region](/docs/sandbox/concepts/regions#regions-and-drives) must match the drive's region. Mount paths must be absolute and cannot overlap with each other.

Drives are mounted as read-write by default. Only one sandbox at a time can mount a given drive as read-write: use [drive snapshots](#snapshots) for shared access.

**index.ts**

```ts filename="index.ts"
import { Drive } from '@vercel/drives';
import { Sandbox } from '@vercel/sandbox';

const drive = await Drive.getOrCreate({ name: 'workspace-cache' });

// Mount as read-write once
const sandbox = await Sandbox.create({
  name: 'my-sandbox',
  region: drive.region,
  mounts: {
    '/data': drive,
  },
});
```

**main.py**

```py filename="main.py"
import asyncio

from vercel import drives, sandbox

async def main() -> None:
    drive, created = await drives.get_or_create_drive(name="workspace-cache")

    # Mount as read-write once
    box = await sandbox.create_sandbox(
        name="my-sandbox",
        region=drive.region,
        mounts={"/data": drive},
    )

asyncio.run(main())
```

**terminal.sh**

```bash filename="terminal.sh"
sandbox create --name my-sandbox --region iad1 --mount workspace-cache:/data
```

In the CLI examples, replace `iad1` with your drive's region if it differs. See [mount options](/docs/sandbox/sdk/cli#sandbox-create) for the supported formats.

#### Snapshots

A drive snapshot checkpoints a drive. It's a read-only, point-in-time save of the drive's files. A drive snapshot is separate from a [sandbox snapshot](/docs/sandbox/concepts/snapshots), which saves a sandbox's whole filesystem. Multiple sandboxes can mount snapshots from the same drive at the same time. Later writes to the drive do not change a snapshot.

Vercel creates an ephemeral snapshot when a sandbox mounts a drive in snapshot mode without a snapshot name. The snapshot captures the latest saved data at mount time. Vercel discards it on unmount.

Create a named snapshot to reuse the same saved data across sandboxes and sessions. Choose a name unique to the drive. Each mount reads the same version until you delete the snapshot or its source drive.

##### Mount ephemeral snapshots

Use ephemeral snapshots when each sandbox needs the drive's latest saved data at mount time.

**index.ts**

```ts filename="index.ts"
import { Drive } from '@vercel/drives';
import { Sandbox } from '@vercel/sandbox';

const drive = await Drive.getOrCreate({ name: 'shared' });

const firstReader = await Sandbox.create({
  name: 'reader-1',
  region: drive.region,
  mounts: {
    '/data': drive.snapshot(),
  },
});
const secondReader = await Sandbox.create({
  name: 'reader-2',
  region: drive.region,
  mounts: {
    '/data': drive.snapshot(),
  },
});
```

**main.py**

```py filename="main.py"
import asyncio

from vercel import drives, sandbox

async def main() -> None:
    drive, created = await drives.get_or_create_drive(name="shared")

    first_reader = await sandbox.create_sandbox(
        name="reader-1",
        region=drive.region,
        mounts={"/data": drive.snapshot()},
    )
    second_reader = await sandbox.create_sandbox(
        name="reader-2",
        region=drive.region,
        mounts={"/data": drive.snapshot()},
    )

asyncio.run(main())
```

**terminal.sh**

```bash filename="terminal.sh"
sandbox create --name reader-1 --region iad1 --mount shared:/data:snapshot
sandbox create --name reader-2 --region iad1 --mount shared:/data:snapshot
```

##### Create and mount a named snapshot

Use a named snapshot when several sandboxes must read the same version of a dataset or cache across runs. Before creating the snapshot, write data to the drive and stop the writer sandbox to save its changes.

**mount-snapshot.mts**

```ts filename="mount-snapshot.mts"
import { Drive } from '@vercel/drives';
import { Sandbox } from '@vercel/sandbox';

const drive = await Drive.get({ name: 'shared' });
const snapshot = await drive.snapshot({ name: 'dataset-v1' });
const reader = await Sandbox.create({
  region: snapshot.region,
  mounts: { '/data': snapshot },
});
console.log(reader.name);
```

**mount\_snapshot.py**

```py filename="mount_snapshot.py"
import asyncio

from vercel import drives, sandbox

async def main() -> None:
    drive = await drives.get_drive(name_or_id="shared")
    snapshot = await drive.create_snapshot(name="dataset-v1")
    reader = await sandbox.create_sandbox(
        region=snapshot.region,
        mounts={"/data": snapshot},
    )
    print(reader.name)

asyncio.run(main())
```

**terminal.sh**

```bash filename="terminal.sh"
vercel drives snapshot shared dataset-v1
sandbox create --region iad1 --mount shared:/data:snapshot:dataset-v1
```

The sandbox can now read the saved dataset at `/data`. Mount the snapshot again to read the same version in another sandbox, or fork it into a new drive to make a writable copy. To list, fork, or delete named snapshots, see the [JavaScript and TypeScript SDK](/docs/drives/sdk-reference#managing-named-snapshots), [Python SDK](/docs/drives/python-sdk-reference#managing-named-snapshots), or [Drives CLI](/docs/drives/cli-reference#vercel-drives-snapshots-list) reference.

### Forking a drive

You can fork an existing drive into a new drive, copying the drive's data and inheriting its region and maximum size. The fork belongs to the same project. Writes to a forked drive do not change the original drive, allowing you to safely edit a copy while preserving the source data. This can be useful to start a fleet of agents, each working independently on their own read-write copy forked from a base drive.

> **💡 Note:** A drive must be mounted read-write and written to at least once before you can
> create a fork from it. Creating a fork of a drive that has never been written
> to fails with a `drive_not_initialized` error.

**index.ts**

```ts filename="index.ts"
import { Drive } from '@vercel/drives';
import { Sandbox } from '@vercel/sandbox';

const drive = await Drive.get({ name: 'workspace-cache' });
const forkedDrive = await drive.fork({ name: 'workspace-cache-fork' });

const sandbox = await Sandbox.create({
  region: forkedDrive.region,
  mounts: { '/data': forkedDrive },
});
```

**main.py**

```py filename="main.py"
import asyncio

from vercel import drives, sandbox


async def main() -> None:
    drive = await drives.get_drive(name_or_id="workspace-cache")
    forked_drive = await drive.fork(name="workspace-cache-fork")

    box = await sandbox.create_sandbox(
        region=forked_drive.region,
        mounts={"/data": forked_drive},
    )


asyncio.run(main())
```

**terminal.sh**

```bash filename="terminal.sh"
vercel drives fork workspace-cache workspace-cache-fork
```

You can mount a forked drive like any other drive. A fork inherit its parent drive data but stores its own changes independently. Use `parentDriveId` to identify the source drive and `rootDriveId` to identify the original drive in a chain of forks.

## Limits

- A sandbox can mount up to 4 drives per run
- A sandbox's main [region](/docs/sandbox/concepts/regions) must match the drive's region

For drive size and quota limits, see [Pricing and limits](/docs/drives/pricing#limits).

## Pricing

Vercel bills drives for storage, reads, and writes. Named snapshots use the same regional storage and read rates as drives. For regional rates and Hobby allotments, see [Drives pricing](/docs/drives/pricing).

## Next steps

- [How Vercel Drives work and how to use them](/kb/guide/vercel-drives): Create, mount, share, and fork a drive step by step, and resolve common errors.
- [Vercel Drives](/docs/drives): Create, manage, fork, and delete drives.
- [Drives pricing](/docs/drives/pricing): Storage, read, and write rates per region.
- [Persistent sandboxes](/docs/sandbox/concepts/persistent-sandboxes): Learn how persistent sandboxes automatically save and restore state.
- [Sandbox snapshots](/docs/sandbox/concepts/snapshots): Save and restore a full sandbox filesystem.
- [CLI Reference](/docs/sandbox/cli-reference): Command reference for the Sandbox CLI.
- [JS SDK Reference](/docs/sandbox/sdk-reference): Full API documentation for the JavaScript SDK.
- [Python SDK Reference](/docs/sandbox/python-sdk-reference): Full API documentation for the Python SDK.

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
