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

# Mount & Unmount a Volume

Volumes provide persistent storage that you can attach to a sandbox at a mount path. You can mount volumes when creating the sandbox, or mount and unmount them at runtime on a running sandbox.

***

## Mount at creation

Pass `volumeMounts` (JS) / `volume_mounts` (Python) to `novita.sandbox.create` — a mapping from mount path inside the sandbox to a `Volume` instance or a volume name.

```js JavaScript & TypeScript icon="js" theme={"system"}
import { Novita } from 'novita-sandbox'

const novita = new Novita()
const volume = await novita.volume.connect('vol_123')

const sandbox = await novita.sandbox.create({
  volumeMounts: {
    '/mnt/data': volume,   // a Volume instance
    '/mnt/shared': 'my-volume-name', // or a volume name
  },
})
console.log('Sandbox created:', sandbox.sandboxId)
```

```python Python icon="python" theme={"system"}
from novita_sandbox import Novita

novita = Novita()
volume = novita.volume.connect("vol_123")

sandbox = novita.sandbox.create(
    volume_mounts={
        "/mnt/data": volume,          # a Volume instance
        "/mnt/shared": "my-volume-name",  # or a volume name
    },
)
print("Sandbox created:", sandbox.sandbox_id)
```

## Mount at runtime

`sandbox.mountVolume(name, path)` / `sandbox.mount_volume(name, path)` attaches a volume by name to a mount path on a running sandbox and returns the updated sandbox information.

```js JavaScript & TypeScript icon="js" theme={"system"}
await sandbox.mountVolume('my-volume-name', '/mnt/data')
```

```python Python icon="python" theme={"system"}
sandbox.mount_volume("my-volume-name", "/mnt/data")
```

```bash CLI icon="terminal" theme={"system"}
novita volume mount <sandbox_id> --name <volume_name> --path /mnt/data
```

## Unmount

`sandbox.unmountVolume(path)` / `sandbox.unmount_volume(path)` detaches the volume mounted at the given path. Pass `force` to force the unmount.

```js JavaScript & TypeScript icon="js" theme={"system"}
await sandbox.unmountVolume('/mnt/data')

// Force unmount
await sandbox.unmountVolume('/mnt/data', { force: true })
```

```python Python icon="python" theme={"system"}
sandbox.unmount_volume("/mnt/data")

# Force unmount
sandbox.unmount_volume("/mnt/data", force=True)
```

```bash CLI icon="terminal" theme={"system"}
novita volume unmount <sandbox_id> --path /mnt/data

# Force unmount
novita volume unmount <sandbox_id> --path /mnt/data --force
```


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