Skip to main content
Mount a drive in a running sandbox to read and write its files at a path you choose. The sandbox must be in the drive’s region. You can’t attach a drive when you create a sandbox; mount it once the sandbox is running.
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 are experimental.
Set up your SDK or the CLI before running these examples. If you belong to more than one team, pass that team on the sandbox client and on each drive call. The examples use a drive named shared-notes, created as in Create a drive, and a running sandbox named hello-world in the same region, created as in Create a sandbox.

Mount a drive

The mount path must be an absolute path that no other mount uses, such as /mnt/notes. A mount lasts until you unmount it. To mount shared-notes at /mnt/notes:
Run the following code:
To confirm the mount: List the sandbox’s drive mounts. The mount at /mnt/notes is in the list. With the CLI set up, you can also write a file and read it back:
The command prints hello. The file stays on the drive after you unmount it or delete the sandbox.

Mount one folder of a drive

Mount a folder of the drive instead of the whole drive. Give the folder’s path from the drive’s root, starting with /. If the folder doesn’t exist, mounting creates it. To mount the drive’s /projects/alpha folder at /mnt/alpha:
Run the following code:

Mount a drive read-only

A read-only mount lets the sandbox read the drive’s files but not change them. Use one for a sandbox that only reads shared inputs. To mount shared-notes read-only at /mnt/notes-ro:
Run the following code:

Share a drive between sandboxes

Mount the same drive in each sandbox that needs its files. Each sandbox mounts it separately, at its own mount path, and can mount it read-write or read-only. To pass a file from one sandbox to another: This procedure uses a second running sandbox named reader in the drive’s region.
  1. Run the following command to write a file from hello-world, where the drive is mounted read-write at /mnt/notes:
  2. Run the following command to mount the drive read-only in reader:
  3. Run the following command to read the file from reader:
    The command prints step 1 done.

List drive mounts

Each mount shows the drive’s name, the folder of the drive that’s mounted (/ for the whole drive), the mount path in the sandbox, and whether it’s read-only. To list the drives mounted in hello-world:
Run the following code:

Unmount a drive

Identify the mount by its mount path. To find it, list the sandbox’s drive mounts. To unmount the drive at /mnt/notes:
Run the following code:
To confirm, list the sandbox’s drive mounts. The mount no longer appears.

Troubleshoot mounting

Next steps

Delete a drive

Permanently remove a drive and its files.

Manage drives

Create a drive, check it, or replace its labels.