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. Set up your SDK or the CLI before running these examples. They 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.
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.

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: Run the following command to write a file to the drive 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 /. To mount the drive’s /projects/alpha folder at /mnt/alpha:
Run the following code with the same sandbox:

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 with the same sandbox:

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.

Troubleshoot mounting

Next steps

List drive mounts

See which drives a sandbox has mounted.

Unmount a drive

Detach a drive from a sandbox and keep its files.