Creating VMs

Anka makes it very simple to get started creating a new VM. Use anka create to create a quick workflow for setting up a new VM. When creating VMs for usage with Anka, you have several methods, detailed below:

Note - VMs are created with spotlight disabled for faster execution and with SIP/Kext Consent disabled by default. It’s strongly advised to keep these settings for optimal Anka performance.
Spotlight can be enabled in the VM with the following command mdutil -i on -a. SIP/Kext Consent can be enabled witht he following command anka modify VMNAME set custom-variable sys.csr-active-config 0.

VMs created are in suspended mode to enable fast boot.

Start the VM

Our VM can now be successfully started. The VM is preconfigured with a default administrative username Anka and password admin. You will see the VM boot up and have to complete the macOS keypad setup steps.

HiSierra VMs

Troubleshooting Tip

If anka create process fails, go to /var/log/install.log and look for error description. It could be due to lack of free space on root or mismatch between the host macOS version and what’s allowed by Apple to install on top of it.

Preparing VM with your dependencies

You can prepare VM with your custom project dependencies in multiple ways.

Option 1

Use the anka create --postinstall flag to include custom scripts. These scripts will run with root privileges after the VM is created and booted. You can also specify multiple scripts separated with comma. They will execute in serial, random manner.

Option 2

Use the anka create --pkg flag to include custom packages to initialize VM, after its created. An example, would be a usercreation pkg.

Option 3

Option 4

Use ‘anka run’ command from host to install dependencies inside the VM.

Using AutoDMG

Creating a VM from macOS .dmg image created with AutoDMG

Anka comes bundled with several scripts in /Library/Application\ Support/Veertu/Anka/tools/ that assist with automation and other tasks. One script in particular, dmg2anka.sh, lets you create a VM from a .dmg using the workflow example below:

After the VM is created, anka will return standard information about the VM, including methods of access you may need. You can view the VM in the Anka Viewer application with anka view testVM or open vnc://:admin@xxx.xxx.xxx.xxx:5904

Manually install the guest add-ons

Once you have completed the macOS installation process, you need to manually set up the paravirtual drivers due to limitations with macOS installers. You will now configure the Anka high performance network and block driver after the macOS setup is complete.

Close the Anka Viewer application and stop the VM with anka stop VMNAME, where VMNAME is replaced with the name of your VM (ours was called testVM above). Then, attach the guest add-ons ISO using the following commands:

Validate by running the following command anka run VMNAME ls -l from the host. It should display ls -l contents of the VM. The VM is correctly created.

The VM is now configured with Anka’s high performance paravirtual network and block drivers.

Anka Guest Add-ons also create a default user - anka, passwd - admin for the VM, which is the default user used by anka run. Start the VM, logout and login as anka user and complete the user setup process for this VM.

Preparing VM with your dependencies

You can prepare VM with your custom project dependencies in multiple ways.

Option 1

Use the anka create --postinstall flag to include custom scripts. These scripts will run with root privileges after the VM is created and booted. You can also specify multiple scripts separated with comma. They will execute in serial, random manner.

Option 2

Use the anka create --pkg flag to include custom packages to initialize VM, after its created. An example, would be a usercreation pkg.

Option 3

Option 4

Use ‘anka run’ command from host to install dependencies inside the VM.

Using an ISO image

Creating an ISO image from .app

If you have a .app file of a version of macOS that is older than what you are currently running on the host, you can first create an .iso from it and then create VM using the .iso in the next section.

Use create_macos_install_image.sh included in the Anka package to create an .iso from your .app installer.

/Library/Application\ Support/Veertu/Anka/tools/create_macos_install_image.sh
Usage: create_macos_install_image.sh install_macos.app [OPTIONS]...
Options:
-g,--guest-addons Embed Anka guest addons in the installer
-o,--output output.iso Specify output image file, if not specified the image will be created in working directory
-p,--pkg path/to/pkg Specify additional packages to include into the installer

To create a VM from .iso, you will use anka create command as you typically would. It will create an empty VM.
Note - > While creating VM with anka create, make sure to specify enough --disk-size. Currently, it’s not possible to change the disk size for an existing VM.

Preparing VM with your dependencies

You can prepare VM with your custom project dependencies in multiple ways.

Option 1

Use the anka create --postinstall flag to include custom scripts. These scripts will run with root privileges after the VM is created and booted. You can also specify multiple scripts separated with comma. They will execute in serial, random manner.

Option 2

Use the anka create --pkg flag to include custom packages to initialize VM, after its created. An example, would be a usercreation pkg.

Option 3

Option 4

Use ‘anka run’ command from host to install dependencies inside the VM.

Instant Start configuration for your VM

Instant availability of build and test emvironment is very critical for CI. Anka provides a way to save the VM in an Instant Start/Fast Boot Mode, before pushing it to Anka Registry for use in your CI.

Use the following command to save the VM in Instant Start mode.

# Suspend the VM
anka suspend VMNAME

Now, when you start the VM using anka start VMNAME command, it will start instantaneously.
Note - Suspend the VM and then push it to Anka Registry.

Hyperthreading configuration setup for Anka VMs when running only a single instance per machine

Hperthreading flag is set at 0 by default. Set it to 1 for a VM, only if you are planning to only run a single instance of this VM on Build node(build physical machine). If you are planning to run multiple concurrent instances of this VM, then don’t set this flag to 1.

anka modify VMNAME set hyper-threading 1

Next steps after your VM setup is complete with your project dependencies

If you have already installed Anka Registry, you can push and store this version of your Anka VM and start managing changes to this VM with different version tags. Once the VM is pushed to the registry, you can distribute it to other machines running Anka.
Refer to Using Registry section to start managing your VMs with the registry.