Skip to content

Storage ​

Every node needs at least one disk. This page covers disk buses and formats, copy-on-write overlays that keep base images clean, named storages shared between nodes, USB disks you can eject at runtime, and Mac folders shared into the guest with VirtioFS.

Disks ​

disks is a list in boot order: UEFI boots from the first bootable disk.

yaml
nodes:
  - name: store
    disks:
      - { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true, size: 16GiB }
      - { bus: virtio, path: data.asif, size: 8GiB }
      - { bus: nvme, path: fast.asif, size: 4GiB }

Each disk sets path or storage, never both. Paths are relative to the lab file; ~ works.

KeyDefaultMeaning
busvirtiovirtio, nvme or usb
pathDisk file. The format comes from the extension.
storageName of an entry in storages
size10GiB with overlaySize of a new file, or the size the guest sees with an overlay
readOnlyfalseAttach read-only
overlayfalseKeep the file as a read-only base and write to a private overlay
cachefalseAdd a cache layer between base and overlay. Needs overlay: true.
cachingautomaticautomatic, cached or uncached
syncfullfull, fsync or none
connectedtrueUSB disks only: inserted at boot

Buses ​

busDeviceIn a Linux guest
virtioVirtio block/dev/vda, /dev/vdb, ...
nvmeNVM Express controller/dev/nvme0n1, ...
usbUSB mass storage, removable at runtime/dev/sda, ...

The cloud-init seed is an extra read-only virtio disk after all of yours.

Formats ​

ExtensionFormatCan vz create it?
.asifApple Sparse Image Formatyes, with diskutil image create blank
.raw, .imgraw diskyes, as a sparse file
.isoISO 9660no, and always read-only

Other extensions are a validation error. qcow2 is not supported: vz image pull converts qcow2 cloud images to raw, and you can do the same with qemu-img convert -O raw.

Create a disk ​

When path does not exist and size is set, vz creates the file on vz up:

yaml
disks:
  - { bus: virtio, path: data.asif, size: 8GiB }

Sizes use binary units: B, KiB, MiB, GiB, TiB, for example 512MiB or 20GiB. Both formats are sparse, so a new disk takes almost no space on the Mac until the guest writes to it. When the file already exists, size is ignored.

The new disk is empty. Format and mount it in the guest, for example with cloud-init's fs_setup and mounts as in the extra disks example.

IMPORTANT

Files you create this way live where path points, usually next to the lab file. They are not in the state directory, so vz node reset and vz destroy do not delete them. Delete them yourself when you want a fresh disk.

Overlays ​

With overlay: true, the disk file is a read-only base, and the node's writes go to a private ASIF overlay in its state directory:

This is how pulled cloud images are meant to be used:

  • many nodes, even in different labs, boot from one base file,
  • the base never changes, so a node is back to a clean install after vz node reset,
  • the overlay only stores the blocks the guest changed.

The base file must exist: an overlay disk is never created from nothing.

Overlay disk size ​

Cloud images are small: the Debian disk is 3GiB, full after the first package install. So an overlay disk is 10GiB by default, whatever the size of its base image (a larger base keeps its own size). The guest's file system grows into it on the first boot, with cloud-init's growpart.

The extra space reads as zeros and costs nothing on the Mac until the guest writes to it: a node that wrote 1GiB takes 1GiB, whatever its disk size.

Set size for a different size, the size the guest sees:

yaml
disks:
  - { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true, size: 64GiB }
  • size must be at least the size of the base image.
  • You can raise it later; the overlay grows on the next vz up.
  • It never shrinks. Lowering size is an error until you run vz node reset <node>.
  • Removing size never shrinks a disk either: it keeps the larger size.

vz only makes the disk bigger. The guest has to grow its partition and file system; cloud images usually do that on boot with cloud-init's growpart module.

Cache layer ​

cache: true adds disk<N>.cache.asif between the base and the overlay. It is meant for a base on slow storage, such as a NAS. It needs overlay: true.

yaml
disks:
  - { path: /Volumes/nas/images/base.raw, overlay: true, cache: true, caching: cached }

Caching and sync ​

caching and sync map to Virtualization.framework's disk image caching and synchronization modes:

KeyValues
cachingautomatic (let macOS decide), cached, uncached
syncfull (safest, the default), fsync, none (no flushes: fastest, but data can be lost if the Mac crashes)

sync: none suits scratch disks you do not mind losing, as on the store node of the node feature tour.

Storages ​

storages defines named disks at the top of the lab file. Nodes refer to them by name. size belongs to the storage, not to the disk that uses it.

yaml
storages:
  reference: { path: reference.asif, size: 1GiB }

nodes:
  - name: store
    disks:
      - { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true }
      - { storage: reference, readOnly: true }
  - name: secure
    disks:
      - { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true }
      - { storage: reference, readOnly: true }

Read-only use can be shared. vz warns when a writable storage, or a writable disk file, is used by more than one node: two VMs writing one disk at the same time corrupt it. Do not run them at the same time.

ISOs and installers ​

ISO files are always attached read-only; validation warns until you write readOnly: true. For an installer, put the ISO on the USB bus so you can eject it after the install, and add an empty disk to install to:

yaml
nodes:
  - name: deb
    cpus: 2
    memory: 2GiB
    disks:
      - { bus: usb, path: ~/.vz/images/debian-13-netinst-arm64.iso, readOnly: true }
      - { bus: virtio, path: root.asif, size: 20GiB }

The full walk-through is the Debian installer example.

USB disks at runtime ​

A usb disk can be ejected and inserted while the node runs. connected: false boots with the disk ejected:

yaml
disks:
  - { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true }
  - { bus: usb, path: usb-stick.asif, size: 1GiB, connected: false }
bash
vz media insert box/1      # <node>/<disk index>: index 1 is the second disk
vz media eject box/1

The index is the disk's position in the node's disks list, starting at 0. connected is only allowed on USB disks. The USB media example formats a stick, ejects it and reads it back.

Shared folders (VirtioFS) ​

Share a folder on the Mac with the guest:

yaml
nodes:
  - name: web
    shares:
      - { tag: site, path: ./site, readOnly: true }
      - { tag: drop, path: ./drop }

Mount it in the guest by its tag:

bash
sudo mount -t virtiofs site /srv/site

or at boot, with cloud-init:

yaml
mounts:
  - [site, /srv/site, virtiofs, "ro,nofail", "0", "0"]
  - [drop, /srv/drop, virtiofs, "rw,nofail", "0", "0"]
KeyMeaning
tagName the guest mounts. Letters, digits, ., _, -, up to 36 characters, unique per node. rosetta is reserved.
pathFolder on the Mac, relative to the lab file. It must exist when the lab starts.
readOnlyThe guest cannot write to the folder. Default false.

TIP

The guest kernel needs the virtiofs driver. The Debian cloud kernel (debian-13) lacks it; use debian-13-generic, as the shared folders example does.

Rosetta ​

rosetta: true shares Apple's Rosetta translator with a Linux guest, so it can run x86_64 Linux binaries. It appears as a VirtioFS share with the tag rosetta:

yaml
nodes:
  - name: desk
    rosetta: true
bash
sudo mount -t virtiofs rosetta /mnt && ls /mnt

Rosetta must be installed on the Mac (softwareupdate --install-rosetta); otherwise vz up fails and says so. Registering it as a binfmt handler in the guest is up to you.

Disk files in the state directory ​

FileRemoved by node resetRemoved by destroy
<state>/<node>/disk<N>.overlay.asifyesyes
<state>/<node>/disk<N>.cache.asifyesyes
<state>/<node>/cidata.isoyesyes
platform files (efi-vars.fd, or mac-* and macos-installed on apple)yesyes
disk files at a path (base images, created disks)nono

See Files and environment for the whole layout.

See also ​