MacVisor

Always-on host

Run a Mac as a virtualization host: headless VMs that start at login and come back after a reboot, and the settings that make that work.

MacVisor can run a Mac as a virtualization host. VMs start at login, run without a window, and come back after a reboot or a power cut. For an overview, see a Mac mini as an always-on VM host.

Turn a VM into a service

  1. In VM Settings → General, turn on Start at Login. Under At Login, choose Start in the background or Start and open its window.
  2. Optionally, turn on Headless under Display.
  3. For USB devices the VM needs, such as a Zigbee radio, remember them once with the USB button in the VM window's toolbar, or with mvz usb remember. They're attached at every start, window or not. See USB devices.
  4. Check on the library dashboard that the background service is running.
mvz autostart <vm> on                 # add --window to open its window at login
mvz start <vm> --headless
mvz wait <vm> --ssh

The background service starts these VMs at every login, whether or not the app opens. You can open a VM's window later without restarting it.

To have a VM started again when it crashes or fails to start, turn on High Availability on the same page, or run mvz ha <vm> on. Stops you ask for, from MacVisor or from inside the guest, are honoured, and a restart it still owes survives a restart of the background service, such as an update's. VM Watchdog can also restart a VM whose guest stops responding, and a health check one whose service stops answering. See High availability.

To be told when a VM stops, or to have an appliance shut down its own way at logout, set hooks: commands run on this Mac after a VM starts or stops, also when the app isn't open. For a VM with a hook, a health check or VM Watchdog on, the background service learns its address and whether its agent answers by itself, every 90 seconds, so MVZ_IP and VM Watchdog work with the app closed.

What VMs do when the Mac logs out or restarts is set once for the whole Mac. See When you log out or restart the Mac.

The chain that has to hold

A VM only comes back after a reboot if every step before it works. When any VM is set to start at login, the dashboard shows an Unattended Auto-Start panel that checks each step.

Power-failure restart, FileVault, automatic login, the background service, and per-VM auto-start each gate the one after it.

StepWhere to set itIf it's missing
Restart after power failuresudo pmset autorestart 1The Mac stays off after a power cut
FileVault offSystem Settings → Privacy & SecurityBoot stops at the unlock screen
Automatic loginSystem Settings → Users & GroupsNo login session, so nothing starts
Background serviceLogin Items & Extensions, or the dashboardNo VM starts
Start at LoginVM Settings → GeneralThat VM stays stopped
The Mac doesn't sleep when idleSystem Settings → Energy → Prevent automatic sleeping when the display is off (on a laptop, System Settings → Battery → Options → Prevent automatic sleeping on power adapter when the display is off), or sudo pmset -c sleep 0The Mac goes to sleep when nobody uses it, and its VMs stop until it wakes: SSH, port forwards and <vm>.mvz names stop answering

MacVisor doesn't keep the Mac awake while VMs run. The Unattended Auto-Start panel shows Sleep when idle and says which setting to change. Unless a laptop is on power with an external display connected (closed-display mode), closing its lid puts it to sleep, whatever these settings say.

The network firewall doesn't wait for a login. MacVisor applies the last firewall policy at boot, so guests come up filtered. See Network firewall.

When a saved session doesn't resume

If VMs suspend at logout, auto-start resumes them. It never throws a saved session away on a guess:

  • The Mac is locked, or the VM's storage isn't mounted yet. The session is kept, and the VM resumes once you unlock the Mac or the storage appears.
  • A disk image the VM writes to changed since it was suspended. Resuming could damage what's on the image now, so the VM stays suspended with its session, and the Tasks pane says why. If you no longer need the session, start the VM from its disk with Start from Disk… or mvz start <vm> --discard-state.
  • The session can't be restored, because macOS was updated or a custom network it needs was deleted. The session goes to the Trash as "VM saved session date", and the VM starts from its disk.
  • Any other failure. MacVisor retries once, then moves the session to the Trash and starts from disk.

Every auto-start and its outcome is listed in the Tasks pane and in Task History.

Managing a Mac you aren't sitting at

Over SSH, mvz covers creating and running VMs, snapshots, clones, networks, firewall rules and licensing. See Using the CLI.

These still need someone at the Mac, or Screen Sharing:

  • approving the background service, the network helper and Local Network access
  • a VM's display
  • the app-only features, such as VLAN interfaces
  • anything that restores a saved session, because macOS requires an unlocked screen

To license a headless Mac, run ssh -t host mvz license activate, or mvz license trial for the trial. The regular license check (every few days) runs while the automatic-login session is up. See Activate your license.

For stable endpoints, use <vm>.mvz names, per-VM port forwards (for this Mac only), a custom network's port forwards for other devices, or DHCP reservations on a custom network.

Capacity

The dashboard compares the vCPUs, memory and disk you've assigned with what the Mac has.

  • vCPUs can be overcommitted. It only hurts when every guest is busy at once.
  • Memory can't. More than the Mac's RAM means swapping under load.
  • Disks are thin-provisioned. Watch the volume's free space, not the disks' logical size.

Keeping it running

  • Each VM runs in its own process, so a crash affects only that VM.
  • App updates don't stop running VMs. With Download and install updates automatically on, the default, they install while the app is closed, unless a VM is suspended. See Updating a Mac you reach only over SSH.
  • Right after the Mac starts, the background service can take a minute to answer. The app waits for it.
  • Snapshots are not backups. Time Machine leaves VMs out, so turn on backups for each VM, to another drive or a share, and back up the host too.