Skip to content

Storage

An instance sees one root filesystem, and whatever is mounted into it. Several disks lie behind them.

    flowchart TB
  root["the guest's /"] --> overlay["the overlay disk<br/>(read-write, the instance's own)"]
  overlay --> image["the image's disk<br/>(read-only, shared)"]
  vol["/data"] --> volume["a volume<br/>(outlives the instance)"]
  

The overlay disk

The guest’s root filesystem is its image, read-only, with a disk of the instance’s own laid over it: its overlay disk. Every change the guest makes, to any file, is written to the overlay disk. It is created on the instance’s first start, with the size --disk gives, 10 GiB by default. It is kept across stops and restarts until the instance is deleted.

Disks are sparse: each takes up only the space the guest has written to it, however large it is.

To give a stopped instance a larger overlay disk, raise its --disk:

$ dicer update web --disk 20GiB

The disk and the filesystem in it grow when the instance next starts, and what the guest has written is kept. An overlay disk cannot shrink, so a size smaller than the disk already has is refused. Restoring a snapshot puts back the disk as it was then, at its size then, and it grows again at the next start.

Volumes

A volume is a disk that exists apart from any instance, for data that must outlive it:

$ dicer volume create pgdata --size 20GiB
$ dicer run -d --mount source=pgdata,target=/data ghcr.io/acme/app:2

It is attached to the guest as a disk of its own and mounted at the target. A volume that is still empty is first populated with what the image has at the target, with its owners and permissions, so the workload can write to it whichever user it runs as. Deleting the instance keeps the volume. A volume is only deleted by dicer volume rm, and not while any instance is defined to mount it.

While an instance can write to a volume, no other instance can use it. The instance keeps the volume to itself while it runs, is paused or is on standby. A volume that every instance mounts read-only can be shared by any number of them. An instance can mount up to 22 volumes.

Rate limits

--disk-rate and --disk-iops limit the bytes and operations per second at which each of an instance’s disks can be read and written. The hypervisor enforces them. See Rate limits.

Mounts

Besides volumes, an instance can mount a copy of a file from the host, a directory on the host, and an empty in-memory filesystem. Each kind suits a different job:

TypeForSourceLifetime
volumeData that must outlive the instanceA volumeUntil the volume is deleted. It outlives the instance.
fileConfiguration from the hostA file on the hostA copy, made at each start. A change on the host reaches the guest at its next start, and a change made in the guest is lost when it stops.
directoryWorking on files from the hostA directory on the daemon’s host, which its configuration allowsShared while the guest runs. A change on either side is seen on the other. Cloud Hypervisor only.
tmpfsScratch spaceNoneIn the guest’s memory. Its contents are lost when the guest stops.

Files and volumes shows how to use each.