Skip to main content
Mount volumes when a machine needs durable shared files. You can declare volumes at machine create time or attach them to an already running machine with the SDK or HTTP API. A machine can have up to 8 active volume attachments. The create-time examples show the Python SDK form first and the equivalent CLI create command second. Runtime examples use the Python SDK and raw HTTP API.

Mount A Volume

Mount paths must be absolute machine paths outside runtime-managed paths such as /workspace/.nullspace.

Mount A Subpath

Expose only one directory from the volume:
subpath is resolved inside the volume and exposes only that subtree at the machine mount path.

Read-Only Mounts

read_only=True prevents writes through the machine mount. Callers with API access can still modify the volume through direct volume.files or nullspace volume ... operations.

Dictionary Mounts

SDK calls also accept dictionaries, which is useful when mount configuration is loaded from JSON:
ref can be a volume name or volume ID.

Runtime Attach And Detach

Attach a volume to a running machine with the same mount descriptor shape used at create time:
List the current attachments for a machine or a volume:
The equivalent HTTP list routes are GET /v1/machines/{id}/volumes and GET /v1/volumes/{id}/attachments. Detach one runtime attachment by ID:
The Python SDK accepts a volume ID, volume name, VolumeMount, or dictionary for machine.attach_volume(...). If read_only is omitted, the runtime API defaults it to false.

Health And Remount

Use health and remount operations when a mounted volume is degraded or after an operator asks you to refresh the live mount:
Attachment states include requested, mounting, mounted, paused, remounting, unmounted, releasing, released, and failed. Destroy the machine to release all remaining volume attachments. Hibernating or pausing a machine releases the live mount lease while the VM is stopped, but it preserves the attachment intent; resume remounts the same volumes. Fork and snapshot restore also remount the stored attachments in the new machine. The CLI currently supports create-time --volume entries. Use the SDK or HTTP API for runtime attach, detach, health, and remount operations.

Snapshot Behavior

Shared volume data is durable storage external to VM memory and mutable rootfs snapshots. Hibernate, resume, and fork remount volume attachments; they do not copy volume data into the VM snapshot.