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.
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.
| Key | Default | Meaning |
|---|---|---|
bus | virtio | virtio, nvme or usb |
path | Disk file. The format comes from the extension. | |
storage | Name of an entry in storages | |
size | 10GiB with overlay | Size of a new file, or the size the guest sees with an overlay |
readOnly | false | Attach read-only |
overlay | false | Keep the file as a read-only base and write to a private overlay |
cache | false | Add a cache layer between base and overlay. Needs overlay: true. |
caching | automatic | automatic, cached or uncached |
sync | full | full, fsync or none |
connected | true | USB disks only: inserted at boot |
Buses
bus | Device | In a Linux guest |
|---|---|---|
virtio | Virtio block | /dev/vda, /dev/vdb, ... |
nvme | NVM Express controller | /dev/nvme0n1, ... |
usb | USB mass storage, removable at runtime | /dev/sda, ... |
The cloud-init seed is an extra read-only virtio disk after all of yours.
Formats
| Extension | Format | Can vz create it? |
|---|---|---|
.asif | Apple Sparse Image Format | yes, with diskutil image create blank |
.raw, .img | raw disk | yes, as a sparse file |
.iso | ISO 9660 | no, 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:
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:
disks:
- { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true, size: 64GiB }sizemust 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
sizeis an error until you runvz node reset <node>. - Removing
sizenever 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.
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:
| Key | Values |
|---|---|
caching | automatic (let macOS decide), cached, uncached |
sync | full (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.
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:
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:
disks:
- { path: ~/.vz/images/debian-13-genericcloud-arm64.raw, overlay: true }
- { bus: usb, path: usb-stick.asif, size: 1GiB, connected: false }vz media insert box/1 # <node>/<disk index>: index 1 is the second disk
vz media eject box/1The 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:
nodes:
- name: web
shares:
- { tag: site, path: ./site, readOnly: true }
- { tag: drop, path: ./drop }Mount it in the guest by its tag:
sudo mount -t virtiofs site /srv/siteor at boot, with cloud-init:
mounts:
- [site, /srv/site, virtiofs, "ro,nofail", "0", "0"]
- [drop, /srv/drop, virtiofs, "rw,nofail", "0", "0"]| Key | Meaning |
|---|---|
tag | Name the guest mounts. Letters, digits, ., _, -, up to 36 characters, unique per node. rosetta is reserved. |
path | Folder on the Mac, relative to the lab file. It must exist when the lab starts. |
readOnly | The 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:
nodes:
- name: desk
rosetta: truesudo mount -t virtiofs rosetta /mnt && ls /mntRosetta 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
| File | Removed by node reset | Removed by destroy |
|---|---|---|
<state>/<node>/disk<N>.overlay.asif | yes | yes |
<state>/<node>/disk<N>.cache.asif | yes | yes |
<state>/<node>/cidata.iso | yes | yes |
platform files (efi-vars.fd, or mac-* and macos-installed on apple) | yes | yes |
disk files at a path (base images, created disks) | no | no |
See Files and environment for the whole layout.
See also
- OS images
- Managing labs:
node resetanddestroy - Lab file reference
- Validation rules