Skip to main content
See Volumes for usage examples and patterns.

Volume

Named volumes are managed by microsandbox and stored at ~/.microsandbox/volumes/<name>/. They persist independently of any sandbox.

Static methods


Volume.create()

static create(config: VolumeConfig): Promise<Volume>
Create a new named volume. Parameters
NameTypeDescription
configVolumeConfigVolume configuration
Returns
TypeDescription
VolumeCreated volume with name and path properties

Volume.get()

static get(name: string): Promise<VolumeHandle>
Get a handle to an existing named volume. Parameters
NameTypeDescription
namestringVolume name
Returns
TypeDescription
VolumeHandleVolume handle

Volume.list()

static list(): Promise<Array<VolumeInfo>>
List all named volumes. Returns
TypeDescription
Array<VolumeInfo>All volumes

Volume.remove()

static remove(name: string): Promise<void>
Delete a named volume and its contents. Fails if the volume is currently mounted. Parameters
NameTypeDescription
namestringVolume name

Mount

Static factory for creating mount configurations used in SandboxConfig.volumes.

Mount.bind()

static bind(path: string, opts?: MountOptions): MountConfig
Mount a host directory into the sandbox. Changes in the guest are reflected on the host and vice versa. Parameters
NameTypeDescription
pathstringDirectory path on the host
opts?{ readonly?: boolean }Mount options

Mount.named()

static named(name: string, opts?: MountOptions): MountConfig
Mount a named volume. The volume must already exist (create it with Volume.create()). Parameters
NameTypeDescription
namestringVolume name
opts?{ readonly?: boolean }Mount options

Mount.tmpfs()

static tmpfs(opts?: TmpfsOptions): MountConfig
Use an in-memory filesystem. Contents are discarded when the sandbox stops. Parameters
NameTypeDescription
opts?{ sizeMib?: number, readonly?: boolean }Tmpfs options

Types

VolumeConfig

FieldTypeDefaultDescription
labels?Record<string, string>{}Metadata labels
namestring-Volume name (required)
quotaMib?number-Maximum storage size in MiB

VolumeHandle

Property / MethodTypeDescription
createdAtnumber | nullCreation timestamp (ms since epoch)
labelsRecord<string, string>Metadata labels
namestringVolume name
quotaMibnumber | nullStorage quota
remove()Promise<void>Delete this volume
usedBytesnumberCurrent disk usage in bytes

VolumeInfo

FieldTypeDescription
createdAtnumber | nullCreation timestamp
labelsRecord<string, string>Metadata labels
namestringVolume name
quotaMibnumber | nullStorage quota
usedBytesnumberCurrent disk usage