Persistent volumes

Block volumes that outlive a sandbox - attach, mount, detach, move to another sandbox, list and erase per project.


A persistent volume is a block device (btrfs, 1 GiB to 64 TiB) mounted at a path you choose. Its data survives stop/start, detaching and the deletion of its sandbox: a sandbox delete keeps its persistent volumes (listed with sandboxDeleted: true; reattach them to another stopped sandbox or erase them at the project level) until you erase them. Pass deleteAttachedVolumes: true to erase them together with the sandbox; a volume moved in from another sandbox is always kept.

Rules#

  • Attach to a stopped sandbox. Attaching to a running sandbox answers 409 ("stop it first"); the volume is mounted at the next start.
  • A delete keeps them. Deleting a sandbox detaches its persistent volumes and keeps them as project volumes (they still count against the project's disk quota). To erase them with it: TypeScript sandbox.delete({ deleteAttachedVolumes: true }), Python await sandbox.delete(delete_attached_volumes=True), Go sb.Delete(ctx, sandal.SandalLifecycleOptions{DeleteAttachedVolumes: true}), CLI sandal delete <id> --yes --delete-volumes.
  • One sandbox at a time. Attaching a volume that is attached elsewhere answers 409 naming the other sandbox; detach it first.
  • Forks do not carry volumes. A fork has only its own workspace disk.
  • Volumes are not available on Full VMs yet.

Attach a new volume and use it#

import { Sandal } from "@sandal-dev/sdk";

const sandal = Sandal.fromEnv();
const sb = await sandal.createSandbox({ name: "with-volume", ttlSeconds: 3600 });
await sb.stop();
await sandal.sandboxes.attachVolume(sb.id, { mountPath: "/data", sizeGiB: 10 });
await sb.start();
await sb.exec(["sh", "-c", "echo kept > /data/state.txt && sync"]);
await sb.stop();
await sb.start();
console.log((await sb.exec(["cat", "/data/state.txt"])).stdout); // kept

Detach, move, erase#

  • sandboxes.detachVolume(sandboxId, { volumeId }) detaches it (the sandbox must be stopped); sandboxes.reattachVolume(otherSandboxId, { volumeId }) attaches the same volume to another stopped sandbox.
  • A volume whose sandbox was deleted (detached first or not) stays in the project list as available with sandboxDeleted: true until you erase it: sandal volumes delete <id> or the Console's Storage page. Erasure takes a few seconds.
  • The project list is sandboxes.listProjectVolumes (TypeScript sandal.raw.sandbox.sandboxes.sandboxesListProjectVolumes(...), Python sandal.sandboxes.list_project_volumes(...)).

Speed#

Measured on production (November 2026): attach a new 1 GiB volume 7-9 s, start with it 6-7 s, detach about 14 s, reattach to another sandbox about 7 s, erase under 8 s.

Not yet available#

Volume snapshots and restore (volume-snapshots in sandal capabilities reads unavailable).