Skip to main content
A volume is a disk that outlives sandboxes. Create it once, mount it into a sandbox when you create the sandbox, and the files you wrote are there the next time you mount it, in a different sandbox, after the first one is gone. A volume is an ext4 disk of fixed size kept on one machine of one region. Mounting it in a sandbox is a disk attach, so reads and writes run at local NVMe speed and every POSIX file operation works (fsync, hard links, xattrs, mmap, flock, direct I/O).

Create a volume

The answer is {"volumeID", "name", "token", "sizeMB", "region", "state", "createdAt"}. sizeMB is in MiB and defaults to 10,240 (10 GiB); the smallest volume is 1,024 and the largest 102,400. sizeBytes is accepted too. region is optional and defaults as for a sandbox create. token is always empty; it is there because the E2B SDK types ask for it. A name is 1 to 128 characters of letters, digits, ., _ and -, starts with a letter or a digit, and is unique in your account: a name you already have answers 409 name_taken. You pay for the size you ask for, not for what you write. A volume cannot be resized.

Mount it

  • name is the volume’s name or its volumeID; path is where the guest mounts it. A path is absolute and normalised, at most 255 bytes, not / and not under /proc, /sys, /dev, /run, /boot or /etc. A sandbox mounts at most 4 volumes, each once, each at its own path.
  • readOnly: true mounts the volume read-only. It still takes the volume for this sandbox alone.
  • The sandbox is started on the machine that keeps the volume, so it waits for capacity on that machine only and answers 503 capacity when it has none. A volume in another region than the create names answers 422 volume_region_mismatch; leave region out to start where the volume is.
  • The disk is mounted before the create answers its first call. The answer and GET /sandboxes/{id} list the mounts as volumeMounts.
  • One sandbox at a time holds a volume. A create that names a volume a running sandbox holds answers 409 volume_busy at once. A sandbox that is killed gives its volumes back before the kill answers, and a create that names the volume of a sandbox still stopping waits for it, so killing a sandbox and mounting its volume in a new one right away works.
A sandbox with a volume is killed, not paused, at its timeout: autoPause and lifecycle.onTimeout: "pause" answer 422 together with volumeMounts. The volume stays; mount it in a new sandbox. Pausing, snapshotting, forking or rewinding such a sandbox answers 409 volume_mounted. Whatever a program wrote is on the volume once its fsync returned, and everything is flushed when the sandbox is killed or ends at its timeout. If the machine itself fails, the volume is lost: a volume is kept on one machine and is not backed up.

List, read and delete

  • GET /volumes lists your volumes, oldest first: [{"volumeID", "name", "sizeMB", "region", "state", "attachedTo"?}]. state is ready, attached or creating.
  • GET /volumes/{volume} reads one by name or id.
  • DELETE /volumes/{volume} removes the data and the name (204). A volume a sandbox holds answers 409 volume_busy (volume is attached to sandbox <id>); kill the sandbox first. The ComputeSDK and E2B SDKs retry that answer for you.

Limits

Volumes are listed with their price on billing.

E2B and ComputeSDK

The E2B shape works as is: Volume.create(name), Volume.list(), Volume.destroy(id) and volumeMounts on a create. The ComputeSDK volume.create/get/list/delete calls and the volumes option of a create map onto the same routes.

Operations