Skip to content

Volumes

A volume is a disk that belongs to your team, not to a sandbox. Mount it when you create a sandbox, and read or write its files directly from your program, with no sandbox running.

from svm import Sandbox, Volume
volume = Volume.create("docs-data", size_gb=1)
try:
# Read and write files with no sandbox running.
volume.write("/notes/hello.txt", "written from outside\n")
print(volume.read_text("/notes/hello.txt"))
# A read-write mount is single-attach: one sandbox at a time.
with Sandbox.create(template="base", volume_mounts=[volume.mount("/mnt/data")]) as sandbox:
sandbox.commands.run("echo 'written in a sandbox' > /mnt/data/notes/sandbox.txt")
print(sandbox.commands.run("ls /mnt/data/notes").stdout)
for entry in volume.list_files("/notes"):
print(entry["name"], entry["kind"], entry["size"])
finally:
volume.delete()

From the CLI:

Terminal window
svm volume create data --size-gb 10
svm sandbox create --template base --volume <volume-id>:/data
svm volume put <volume-id> ./notes.txt /notes.txt
svm volume cat <volume-id> /notes.txt