Creating your first VM

Create your first VM using the Anka CLI.

Install the Anka CLI

For Anka CLI commands and options, see the Command Reference.

Understanding VM Templates, Tags, and Disk Usage

Anka VM “Templates” contain the base macOS installation and are optimized to minimize disk usage.

You can create Templates using anka create.

Our getting started guide has some great information on scripting the download of a macOS installer package.

At this time, Anka VM Templates only support the following macOS versions:

  • 10.15.x (macOS Catalina)
  • 10.14.x (macOS Mojave)
  • 10.13.x (macOS Hi Sierra)
  • 10.12.x (macOS Sierra)
  • 10.11.x (macOS El Capitan)
  • 10.10.x (macOS Yosemite)

After a Template is created, you can use anka view and anka run commands to install and configure whatever dependencies and software you need inside of the VM.

Once you've installed everything you need in a VM, you can then use anka suspend to save the state of the VM.

Saving it as suspended allows for quick boot when you run anka start

Suspending (vs stopping) the VM uses more disk space as ram is saved to disk

You can then push the Template to the Registry using anka registry push and set the Tag. Or, use anka registry push -l {template} -t {tag} to only create the Tag locally (useful if you're not using a registry).

Our use of Tags is similar to docker

Tags contain only the delta from the base Template or previous Tag, saving a lot of disk space and bandwidth. They can be built in a sequence from the base Template, each new Tag receiving the contents of the last Tag.

Tags store state of the VM Template. So, if you've got Template1 and a Tag named Tag1 for it, then clone Template1 to Template2, Template2 will contain everything Template1/Tag1 had but not yet have a Tag of its own.

If you're interested in Infrastructure as Code to automate the creation of your Templates and Tags, you have several options:

  1. Write scripts that:
    • Parse and iterate commands, in order, from a data serialization language like JSON and execute them inside of the VM before suspending and pushing to the Registry.
    • Or execute commands on the VM from within the script itself (example).
  2. Use the Packer Builder: https://github.com/veertuinc/packer-builder-veertu-anka

Lastly, each Template and specific/current Tag can be cloned to create a new Template. You have two options:

  1. Use anka clone without -c (recommended): The new cloned Template will have no Tags, but will link to the layers/contents from the previous Template and Tag's state. No new disk space will be used until you modify that new Template. The Tag you create on the new Template will only contain the delta.
  2. Use anka clone with -c: The new cloned Template will have no Tags, but will link to the layers/contents from the previous Template and Tag's state. An independent copy of the Template and Tag will be made, in many cases doubling the disk usage.

When creating a clone without -c, deletion of the first Template will not delete the contents of the second cloned Template. Anka CLI will intelligently know that the layers are still in use by the new Template.

Creating a VM Template

Obtain the macOS installer

There are multiple ways to obtain the installer .app file for Mac OSX that we'll detail for you below:

  1. If you have a pending upgrade to the next minor or patch version of Mac OS:

    • Within Preferences -> Software Update -> Advanced, make sure Download new updates when available is checked but Install macOS updates is not. While you're still within Software Update, click Update Now but do not install the next version (Restart) until after you've created the Anka VM or the Install .app under /Applications will be deleted.
    • You can also use the App Store to download the installer.
  2. On Catalina, you can use softwareupdate: sudo softwareupdate --fetch-full-installer --full-installer-version 10.15.6

  3. Have your local IT department provide a network volume or download links.

  4. On any Mac OS version you can use the installinstallmacos.py script (requires python):

    This method doesn't consistently work and can throw errors like uses a deprecated pre-10.2 format

    • Download and run the script:

      curl --fail --silent -L -O https://raw.githubusercontent.com/munki/macadmin-scripts/main/installinstallmacos.py
      sudo chmod +x installinstallmacos.py
      sudo ./installinstallmacos.py --raw
      
    • The script downloads an image to the location of the .py script, so further steps are necessary to unpack the .app:

      mkdir -p /tmp/app
      hdiutil attach "<installinstallmacos.py image path>" -mountpoint /tmp/app
      cp -r "/tmp/app/Applications/Install Mac OS Catalina.app" /Applications/
      hdiutil detach /tmp/app -force
      rm -f "<installinstallmacos.py image path>"
      

Generate the Template

sudo anka create --app /Applications/Install\ macOS\ Catalina.app/ 10.15.4

We recommend adding a version to the Template name so it's clear what version of OSX it is.

The VM creation should take around 30 minutes.

The advanced guide for creating Templates and Tags can be found here.