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

# Unmount a drive

> Detach a drive from a sandbox. The drive and its files stay.

Unmount a [drive](https://docs.baseten.co/drives/overview.md) when a sandbox no longer needs it. The
drive and its files stay, and other sandboxes keep their mounts.
[Set up your SDK or the CLI](https://docs.baseten.co/drives/create-drives.md#set-up) before running these
examples. They use a sandbox named `hello-world` with a drive mounted at
`/mnt/notes`, as in [Mount a drive](https://docs.baseten.co/drives/mount-drives.md).

> [!NOTE]
>
> Drives are in pre-release in the Baseten CLI (`baseten drive` and `baseten sandbox drive`) and in the Python, TypeScript, and Go SDKs (`baseten`, `@basetenlabs/client`, `@basetenlabs/sandbox`, and `baseten-go`). Commands, methods, and responses can change. The [Management API drive operations](https://docs.baseten.co/reference/management-api/overview.md#drives) are experimental.

## Unmount a drive

Identify the mount by its mount path. To find it, [list the sandbox's drive
mounts](https://docs.baseten.co/drives/list-drive-mounts.md).

**To unmount the drive at `/mnt/notes`**:

> [tab] TypeScript
>
> Run the following code:
>
> ```typescript theme={"system"}
> import { SandboxClient } from "@basetenlabs/sandbox";
>
> const client = new SandboxClient({ apiKey: process.env.BASETEN_API_KEY! });
> const sandbox = await client.get({ name: "hello-world" });
> await sandbox.drives.unmount({ mountPath: "/mnt/notes" });
> ```

> [tab] Python
>
> Run the following code:
>
> ```python theme={"system"}
> import os
>
> from baseten.sandbox import SandboxClient
>
> with SandboxClient(api_key=os.environ["BASETEN_API_KEY"]) as client:
>     sandbox = client.get(name="hello-world")
>     sandbox.drives.unmount(mount_path="/mnt/notes")
> ```

> [tab] Go
>
> Run the following code:
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "log"
>     "os"
>
>     "github.com/basetenlabs/baseten-go/sandbox"
> )
>
> func main() {
>     ctx := context.Background()
>     client, err := sandbox.NewClient(sandbox.ClientOptions{
>         APIKey: os.Getenv("BASETEN_API_KEY"),
>     })
>     if err != nil {
>         log.Fatal(err)
>     }
>     sb, err := client.Get(ctx, sandbox.GetOptions{Name: "hello-world"})
>     if err != nil {
>         log.Fatal(err)
>     }
>     if err := sb.Drives().Unmount(ctx, sandbox.DriveUnmountOptions{MountPath: "/mnt/notes"}); err != nil {
>         log.Fatal(err)
>     }
> }
> ```

> [tab] API
>
> Set `SANDBOX_URL` to the sandbox's URL, as in
> [Get the sandbox URL](https://docs.baseten.co/sandboxes/run-commands.md#get-the-sandbox-url).
> The mount path goes in the URL, with each `/` encoded as `%2F`.
>
> Run the following command to
> [unmount the drive](https://docs.baseten.co/reference/sandbox-api/drive/detach-a-drive-from-a-local-path.md):
>
> ```bash theme={"system"}
> curl --request DELETE \
>   --url "${SANDBOX_URL%/}/drives/mount/%2Fmnt%2Fnotes" \
>   --header "Authorization: Bearer $SANDBOX_TOKEN"
> ```
>
> The response's `success` field is `true`.

> [tab] CLI
>
> Run the following command:
>
> ```bash theme={"system"}
> baseten sandbox drive unmount --name hello-world --mount-path /mnt/notes
> ```
>
> The command prints `Unmounted the drive at /mnt/notes.`

To confirm, [list the sandbox's drive mounts](https://docs.baseten.co/drives/list-drive-mounts.md). The
mount no longer appears.

## Next steps

> [card] [Delete a drive](https://docs.baseten.co/drives/delete-drives.md)
>
> Permanently remove a drive and its files.

> [card] [Mount a drive](https://docs.baseten.co/drives/mount-drives.md)
>
> Mount the drive again in this sandbox or another one.
