Skip to main content

Volumes Workflow

This guide walks through the full volume lifecycle: create, transfer files, checkpoint, mount on new/existing VMs, unmount, and cleanup.

Prerequisites

pip install instavm

You need a valid API key from the InstaVM Dashboard.

1) Create a volume

from instavm import InstaVM

client = InstaVM(api_key="your_api_key")

volume = client.volumes.create(
name="project-data",
quota_bytes=10 * 1024 * 1024 * 1024, # 10 GiB
)

volume_id = volume["id"]
print("volume:", volume_id)

2) Upload, list, download, and delete files without mounting

# Upload
client.volumes.upload_file(
volume_id=volume_id,
file_path="./README.md",
path="docs/README.md",
overwrite=True,
)

# List
files = client.volumes.list_files(
volume_id=volume_id,
prefix="docs/",
recursive=True,
limit=1000,
)
print("files:", len(files))

# Download
download = client.volumes.download_file(
volume_id=volume_id,
path="docs/README.md",
)
print(download["filename"], download["size"])

# Delete
client.volumes.delete_file(
volume_id=volume_id,
path="docs/README.md",
)

3) Create and manage checkpoints

checkpoint = client.volumes.create_checkpoint(
volume_id=volume_id,
name="pre-release",
)

checkpoints = client.volumes.list_checkpoints(volume_id=volume_id)
print("checkpoints:", len(checkpoints))

client.volumes.delete_checkpoint(
volume_id=volume_id,
checkpoint_id=checkpoint["id"],
)

4) Mount on a newly created VM

vm = client.vms.create(wait=True)
vm_id = vm["vm_id"]

mounted = client.vms.mount_volume(
vm_id=vm_id,
volume_id=volume_id,
mount_path="/data",
mode="rw",
wait=True,
)
print(mounted)

5) Hot-plug on an existing/running VM

Use the same mount API against an already-running VM.

client.vms.mount_volume(
vm_id=vm_id,
volume_id=volume_id,
mount_path="/mnt/hotplug",
mode="rw",
wait=True,
)

6) Unmount and cleanup

Unmount requires mount_path.

client.vms.unmount_volume(
vm_id=vm_id,
volume_id=volume_id,
mount_path="/data",
wait=True,
)

client.volumes.delete(volume_id=volume_id)

Important flags and when to use them

FlagWhereWhy it matters
refresh_usagevolumes.list/getRefreshes usage metrics before returning
overwriteuploadControls replacement behavior for existing file path
prefixlist filesRestricts list scope to a subtree
recursivelist filesIncludes nested paths when true
limitlist filesCaps result count per list call
modemountrw or ro access mode
checkpoint_idmountAttach using a specific checkpoint context
waitmount/unmount/create vmBlock until operation completes
mount_pathmount/unmountIn-VM path; required for unmount

Operational notes

  • Keep mount paths explicit and consistent (/data, /mnt/cache, etc.).
  • Use checkpoints before destructive writes.
  • Keep volume quotas aligned with workload expectations to avoid write failures.
  • Treat volumes as durable file storage, not as managed transactional databases.

Next steps