Optimizing your VM

Post-creation tuning for CI and automation workloads

Apply these changes inside the guest after creating and before you push a template to the registry.

Disable Spotlight indexing

sudo defaults write ~/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array "/Volumes" || true
sudo defaults write ~/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array "/Network" || true
sudo killall mds || true
sleep 60
sudo mdutil -a -i off / || true
sudo mdutil -a -i off || true
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist || true
sudo rm -rf /.Spotlight-V100/*
rm -rf ~/Library/Metadata/CoreSpotlight/ || true
killall -KILL Spotlight spotlightd mds || true
sudo rm -rf /System/Volumes/Data/.Spotlight-V100 || true

Disable SIP

anka create disables SIP automatically. GUI-created VMs need manual SIP disable.

With SIP enabled, syspolicyd scans processes and slows CI workloads.

Disable unused macOS services

These scripts stop launchd agents and daemons that a CI guest does not use. Examples are Siri, iCloud, Photos, and analytics. In one guest test, RAM use fell by almost 3 GB.

Run the script in the guest after you disable SIP. You can also run the same script on the host when SIP is disabled on the host.

The scripts disable services for user ID 501 (gui/501). The default Anka user is user ID 501.

Both scripts disable Screen Sharing (com.apple.screensharing and the related agents). Anka enables Screen Sharing so you can open the guest with VNC. Delete those names from the list when you still need VNC. Remote Login stays enabled, so SSH continues to work.

The scripts record the disabled services in /private/var/db/com.apple.xpc.launchd/. To restore the services, delete those records and reboot:

sudo rm -r /private/var/db/com.apple.xpc.launchd/*

Adapt the lists to your workload. Source: b0gdanw, based on disable.sh by pwnsdx.

macOS 11 through macOS 15

Use this script on macOS Big Sur (11) through macOS Sequoia (15). Source: Disable Sequoia bloatware.

macOS 27

Use this script on macOS Golden Gate (27). Source: Disable macOS Golden Gate bloatware.

What’s next