~/.microsandbox/volumes/<name>/. They persist independently of any sandbox. There is no Rust-side resource to release: Remove deletes the on-disk state and the DB record.
Functions
CreateVolume()
Example
Example
*Volume with its name and host path. Configure the kind, quota, disk size, and labels with option functions. Returns ErrVolumeAlreadyExists if a volume with the given name already exists.
Parameters
ctxcontext.Contextnamestringopts…VolumeOptionReturns
Name and Path.GetVolume()
Example
Example
ErrVolumeNotFound if no such volume exists.
Parameters
ctxcontext.ContextnamestringReturns
ListVolumes()
Example
Example
Parameters
ctxcontext.ContextReturns
RemoveVolume()
Example
Example
Parameters
ctxcontext.ContextnamestringVolume methods
AVolume is returned by CreateVolume and carries the volume’s name and host path.
v.Name()
v.Path()
v.FS()
Example
Example
*VolumeFs for direct host-side file operations on this volume.
Returns
v.Remove()
Example
Example
RemoveVolume(ctx, v.Name()).
VolumeHandle methods
AVolumeHandle is the metadata reference returned by GetVolume and ListVolumes.
h.Name()
h.Path()
h.Kind()
VolumeKindDir or VolumeKindDisk.
Returns
h.QuotaMiB()
nil if unlimited.
h.UsedBytes()
h.CapacityBytes()
nil for directory volumes.
h.DiskFormat()
nil for directory volumes.
h.DiskFstype()
nil for directory volumes.
h.Labels()
h.CreatedAt()
time.Time value if unknown.
h.FS()
*VolumeFs for direct host-side file operations on this volume.
Returns
h.Remove()
RemoveVolume(ctx, h.Name()).
VolumeFs methods
Host-side filesystem operations on a named volume’s data directory. Obtain viaVolume.FS() or VolumeHandle.FS(). These operations run directly on the host filesystem: no running sandbox is required and no agent protocol is involved.
All path arguments are relative to the volume root. Paths that would escape the root via .., absolute components, or stray symlink chains are rejected with ErrPathEscape.
vfs.Root()
vfs.Read()
Parameters
relPathstringReturns
vfs.ReadString()
vfs.Write()
0o644.
Parameters
relPathstringdata[]bytevfs.WriteString()
0o644.
vfs.Mkdir()
0o755).
vfs.Remove()
vfs.RemoveAll()
vfs.Exists()
Returns
true if a file or directory exists at the path.Options
Functional options passed toCreateVolume, plus the Mount factory helpers that attach a volume, bind mount, tmpfs, or disk image to a sandbox via WithMounts.
WithVolumeKind()
VolumeKindDir (default) and VolumeKindDisk.
Parameters
kindVolumeKindWithVolumeSize()
VolumeKindDisk.
Parameters
mebibytesuint32WithVolumeQuota()
Parameters
mebibytesuint32WithVolumeLabels()
Parameters
labelsmap[string]stringMount.Bind()
MountOptions.QuotaMiB to bound how much the guest may write beyond the host directory’s existing contents, overriding the runtime’s protective default. Returns a MountConfig for use with WithMounts.
Parameters
hostPathstringoptsMountOptionsExample
Example
Mount.Named()
Example
Example
CreateVolume). Returns a MountConfig.
Parameters
namestringoptsMountOptionsMount.NamedWith()
Example
Example
NamedVolumeOptions.Mode accepts "existing" (default), "create", or "ensure-exists". Mode: "create" fails when the named volume already exists. Mode: "ensure-exists" creates the volume if it is missing and reuses a compatible existing volume; it errors when the existing volume has a different kind, quota, or capacity than requested, and never mutates existing volume metadata.
Parameters
namestringoptsMountOptionsnamedOptsNamedVolumeOptionsMount.Tmpfs()
Example
Example
MountConfig.
Parameters
optsTmpfsOptionsMount.Disk()
Example
Example
MountConfig.
Parameters
hostPathstringoptsDiskOptionsTypes
Volume
A named persistent volume carrying its host-side path. Returned byCreateVolume. Lookups via GetVolume and ListVolumes yield richer VolumeHandle values instead.
Returned by CreateVolume()
VolumeHandle
Metadata reference for a named volume. Obtain viaGetVolume or ListVolumes.
Returned by GetVolume() · ListVolumes()
VolumeFs
Host-side filesystem operations on a volume’s data directory. Obtain viaVolume.FS() or VolumeHandle.FS(). All path arguments are relative to the volume root; escaping paths are rejected with ErrPathEscape.
Returned by Volume.FS() · VolumeHandle.FS()
ErrPathEscape
VolumeFs method when relPath is absolute, contains a .. sequence that resolves outside the volume root, or otherwise escapes the volume’s directory after filepath.Clean.
Returned by VolumeFs methods
VolumeConfig
The config struct populated byVolumeOption functions. Most callers go through CreateVolume(ctx, name, opts...); VolumeConfig is exported for callers that prefer to construct one directly.
Mutated by VolumeOption
VolumeOption
CreateVolume. Constructed by the WithVolume* helpers.
Used by CreateVolume()
VolumeKind
Used by VolumeConfig · WithVolumeKind() · VolumeHandle.Kind()
MountConfig
Discriminated mount configuration produced by theMount factory helpers and passed to WithMounts. Construct it with the factory rather than by hand: the factory sets the internal kind discriminator and enforces the mutually-exclusive flavours. Inspect the flavour via Kind().
Returned by Mount.Bind() · Mount.Named() · Mount.NamedWith() · Mount.Tmpfs() · Mount.Disk()
MountKind
mount.Kind().
Returned by MountConfig.Kind()
MountOptions
Tuning struct forMount.Bind, Mount.Named, and Mount.NamedWith. StatVirtualization and HostPermissions are virtiofs-only and rejected at build time if combined with a tmpfs or disk-image mount; their zero values preserve the conservative defaults (strict, private).
Used by Mount.Bind() · Mount.Named() · Mount.NamedWith()
NamedVolumeOptions
Tunes sandbox-time named volume provisioning forMount.NamedWith.
Used by Mount.NamedWith()
TmpfsOptions
Tuning struct forMount.Tmpfs.
Used by Mount.Tmpfs()
DiskOptions
Tuning struct forMount.Disk.
Used by Mount.Disk()