MacVisor

Linked clones

Fork a VM instantly by sharing its disk instead of copying it, and what the shared base means for both VMs.

A linked clone forks a VM without copying its disk. The source's disk becomes a read-only base, and each VM writes to its own layer on top. A linked clone is instant and takes no extra space, whether the disk holds 60 GB or 600 GB.

The sealed base disk at the bottom, with the source VM's and each linked clone's writable overlay stacked on top of it; writes land in the overlay and reads fall through to the base.

Use them for a test matrix, a VM per branch, or CI workers from one golden image. Every VM made from a cloud image is already a linked clone of that image's template.

Create one

Right-click a stopped VM and choose Linked Clone…, or run mvz clone <vm> <name> --linked. The source must be stopped, have no suspended session, and have an ASIF boot disk. To convert a raw disk, see Storage and sharing. You can clone a clone.

A linked clone's Overview names its base: the Storage card says Linked clone of "ubuntu-base", and its notes start with what it was made from and when. Click the name to select the base. mvz show <vm> prints the same as Made from.

What changes for the source

The source VM keeps working, but its disk is now shared, which limits a few operations on both sides.

OperationSource VMLinked clone
Start, stop, suspend, snapshotYesYes
Resize the boot diskGrow onlyGrow only
Full clone, or convert to a templateYesOnly if made from a template
ExportYesAfter mvz flatten
Clone from one of its snapshotsNoOnly if made from a template
Delete, or revert to a snapshotAfter its clones are deletedYes

A VM made from a template can be full-cloned or made into a template because templates never change while VMs use them. A clone of an ordinary VM can't, because part of its disk lives in that VM's package.

Delete in the right order

Delete clones before their source. MacVisor refuses to delete or revert a VM while clones depend on it, and names them.

When you delete the last clone, and it has left the Trash, the source gets its own layer back, as long as it hasn't run since the fork and has no snapshots from that time. Otherwise the VM's Overview shows how much space unused layers hold, with Flatten Disk to merge them. mvz flatten <vm> does the same for a stopped VM without snapshots. Layers nothing reads any more go to the Trash, or are deleted on a drive with no Trash, such as a network share.

A clone in the Trash

A linked clone you move to the Trash can be put back, and it still starts: its source keeps the shared layers the clone reads for as long as the clone is in the Trash, or in a storage location you removed from MacVisor's list. Meanwhile:

  • the source can't be reverted to a snapshot, and a template the clone was made from can't be turned back into a VM. MacVisor names the clone, with "(in the Trash)";
  • Flatten Disk on the source keeps the layers the clone reads.

Empty the clone from the Trash, or put it back and flatten its disk, to lift this.

Which kind of copy

Linked cloneFull cloneTemplate
Disk costNoneA copy of the diskA copy per VM
SpeedInstantAs fast as the copyAs fast as the copy
Independent of its sourceNoYesYes
Best forMany short-lived VMsA VM you keep and moveA base you stamp copies from

A full clone on the same APFS volume is copy-on-write too, so it is cheaper than it sounds. A linked clone's base stays shared as both VMs change, so it stays cheap over time.

mvz clone <vm> <name>                      # full copy
mvz clone <vm> <name> --linked             # linked clone
mvz clone <vm> <name> --snapshot <id>      # a copy of the VM at that snapshot
mvz flatten <vm>                           # make a layered disk self-contained; asks first, --yes in a script