Skip to content

vm_disk volumes

A vm_disk volume stores block disks for virtual machines and sandboxes. A guest sees each disk as a normal block device. Versions, named refs, and clones turn one prepared disk into many sandboxes.

What a vm_disk volume is

The volume type is vm_disk. A vm_disk volume has its own encryption key and storage location, like any other volume. One volume holds many disks. Each disk has a fixed size and a kind of root, data, or memory.

A vm_disk volume holds block disks only. A host agent on a Linux host serves them as block devices. Mount commands refuse the type.

Disks, versions, refs, and sessions

  • Version. An immutable state of a disk. A version records its parent, its size, its logical bytes, and its physical bytes. Physical bytes count the unique stored bytes. A version is live, deleting, dead, or pending.
  • Ref. A name for a version, such as an image name. A ref moves to another version in one checked step. A fixed ref keeps the version it has.
  • Session. One attachment of a disk to a host. A session reads from a base version and keeps its own writes. A session is attached, detached, or discarded.

Seal and clone

Seal turns the writes of a session into a new version. The host agent seals one or more disks of a guest at one pause point.

Clone creates new disks from a sealed version. Each child starts with the content of that version and gets its own session. The writes of a child stay private to that child. A clone call reports a result for each child, so one failed child leaves the others in place.

Session modes

  • ephemeral. Writes stay on the local disk of the host. A host crash ends the session.
  • streamed (default). A flush completes on the local disk, and the host sends the writes to storage in order. A host crash can lose the most recent flushed writes.
  • durable. A flush completes after storage holds the data. A completed flush survives a host crash.

Isolation

Each vm_disk volume has its own encryption key and storage location. Disks of different volumes share no data. Identical data inside one volume is stored once, and the disks of that volume share it. Storage credentials stay on the servers. The host agent logs in with the access key of the volume.

Create a volume

The Admin API and SDK create a vm_disk volume with the same call as any other volume. The storage of the volume is an object or block storage.

ts
const { id: volumeId } = await client.volumes.create({
  accountId, storageId,
  name: 'sandboxes',
  volumeType: 'vm_disk',
  encryption: true,
})

Attach a disk to a VM

The mountos vmdisk commands run and control the host agent on Linux. The agent serves each attached disk as one endpoint. A vhostuser endpoint is a vhost-user-blk socket for a virtual machine monitor. A ublk endpoint is a block device on the host.

sh
# one agent per Linux host
mountos vmdisk serve --host-id 7 --discovery-url https://hub.example.com

# attach a disk as a vhost-user-blk socket (default) or a ublk block device
mountos vmdisk attach --volume 12 --disk 3 --creds-file ~/vol12.json --name sbx1
mountos vmdisk attach --volume 12 --base-ref ubuntu-base --creds-file ~/vol12.json \
  --name sbx2 --kind ublk --mode durable

mountos vmdisk list
mountos vmdisk seal sbx1 sbx2
mountos vmdisk detach sbx1

The volume login goes to the agent through a file of mode 0600 or through stdin. The agent keeps it in memory only. When the agent stops, it removes its endpoints and detaches every session. The resume command attaches the row of a detached session again.

What operators see

The admin dashboard lists vm_disk volumes with a type badge. The VM Disks tab of a volume shows disks, a version tree, refs, and sessions. It can clone a version and create, move, or delete a ref. A system admin can detach or discard a session.

The Admin API serves the same data under /api/v1/volumes/:volumeId/forks/:forkName/vmdisk. The SDK exposes it as the vmDisks resource in TypeScript, Go, and Rust. A list answer holds one page, and a write accepts an opKey so a retry repeats the first result.

ts
const clones = await client.vmDisks.cloneVersion(volumeId, forkName, versionId, {
  count: 4,
  mode: 'ephemeral',
})

More

↑↓ to navigate ↵ to open