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 options, detailed below:

NOTE - Use anka --machine-readable to get machine readable output from all anka commands.

Using macOS Installer Application

Note - This method uses Apple installer application feature, which by default doesn’t allow installation of versions older than what is running on the host. To install older OS versions than what your host has, please follow the guide below, Using .iso format macOS installer images to create your VMs.

anka create lets you create a VM.

anka create --ram-size 4G --cpu-count 2 --disk-size 20G --app /Applications/Install\ macOS\ High\ Sierra\ Beta.app build73sierra
Installing macOS 10.13...
Copying addons... 100.%
Converting to ANKA format...
20480+0 records in
Preformatting hard drive
vm created successfully with uuid: 8f0e1111-a14b-11e7-aaa4-003ee1cbb8b4

Options flag available with anka create command

anka create --help
Usage: anka create [OPTIONS] VMNAME

  Creates a VM

Options:

  -m, --ram-size TEXT       ram size in G  [default: 3G; optional]
  -o, --optical-drive PATH  path to disk file  [optional]
  -h, --no_hyperthreading   [optional]
  -c, --cpu-count INTEGER   the number of cpu cores  [default: 2; optional]
  --disk-size TEXT          sets the disk size when creating a new disk, use G suffix for GB M suffix for MB or no suffix for
                            bytes  [default: 60G; optional]
  -n, --no-preformat        [optional]
  -a, --app PATH            Path to Install macOS Application (downloadable from AppStore)  [optional]
  -p, --pkg PATH            Additional package to be installed  [optional]
  -s, --postinstall PATH    Postinstall scripts (to run with root credentials at first boot) [optional]
  --help                    Show this message and exit.  [optional]

HiSierra VMs

Anka supports creating and running HiSierra VMs on machines running Sierra or HiSierra as the base macOS.

Starting the VM

Our VM can now be successfully started. The VM is preconfigured with an administrative username Anka and password admin.

$ anka start anka-mactest3
VM anka-mactest3 successfully started
+-----------------------+--------------------------------------+
| uuid                  | 8dc38a59-3945-11e7-a2a7-3c15c2d440ca |
+-----------------------+--------------------------------------+
| name                  | anka-mactest3                        |
+-----------------------+--------------------------------------+
| cpu_cores             | 2                                    |
+-----------------------+--------------------------------------+
| ram                   | 2G                                   |
+-----------------------+--------------------------------------+
| image_id              | 80d39bc0-3941-11e7-8eed-3c15c2d440ca |
+-----------------------+--------------------------------------+
| status                | running                              |
+-----------------------+--------------------------------------+
| vnc_port              | 5900                                 |
+-----------------------+--------------------------------------+
| vnc_connection_string | vnc://:admin@10.0.1.20:5900          |
+-----------------------+--------------------------------------+
| vnc_password          | admin                                |
+-----------------------+--------------------------------------+
| view_vm_display       | anka view anka-mactest3           |
+-----------------------+--------------------------------------+

Preparing VM with your dependencies

You can prepare VM with your custom dependencies in two 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.

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 spave on root or mismatch between the host macOS version and what’s allowed by Apple to install on top of it.

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:

Converting your AutoDMG image

# Change into Anka tools working directory
cd /Library/Application\ Support/Veertu/Anka/tools/

# Convert the AutoDMG-generated .dmg to an Anka VM
./dmg2anka.sh /path/to/autodmg-generated.dmg VMNAME

Starting the VM and completing the macOS installation

Start the VM:

anka start VMNAME

+-----------------------+--------------------------------------+
| uuid                  | 67044c57-3a65-11e7-84bd-38c98630393f |
+-----------------------+--------------------------------------+
| name                  | VMNAME                               |
+-----------------------+--------------------------------------+
| cpu_cores             | 2                                    |
+-----------------------+--------------------------------------+
| ram                   | 2G                                   |
+-----------------------+--------------------------------------+
| image_id              | 48c8cb23-3a65-11e7-a2cb-38c98630393f |
+-----------------------+--------------------------------------+
| status                | running                              |
+-----------------------+--------------------------------------+
| vnc_port              | 5904                                 |
+-----------------------+--------------------------------------+
| vnc_connection_string | vnc://:admin@xxx.xxx.xx.xxx:5904     |
+-----------------------+--------------------------------------+
| vnc_password          | admin                                |
+-----------------------+--------------------------------------+
| view_vm_display       | anka view VMNAME                     |
+-----------------------+--------------------------------------+

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:

# Remove the existing optical drive with the .iso installer
anka modify VMNAME delete optical-drive 0

# Add new optical drive with paravirtual driver installer image
anka modify VMNAME add optical-drive --file /Library/Application\ Support/Veertu/Anka/guestaddons/anka-addons-mac.iso

Then, start and view the VM using the commands below:

# Start the VM
anka start VMNAME

# View the VM in the Anka Viewer application
anka view VMNAME

Install the guest add-ons inside the VM. Close the Anka Viewer and execute the following commands:

# Stop the VM
anka stop VMNAME

# Remove the Guest Add-on drive
anka modify VMNAME delete optical-drive 0

# Set the VM hard-drive and network to use the paravirtual drivers 
anka modify VMNAME set hard-drive --controller ablk 0
anka modify VMNAME set network-card --model anet 0

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.

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

For example:

/Library/Application\ Support/Veertu/Anka/tools/create_macos_install_image.sh /Applications/Install\ macOS\ Sierra.app

Using an ISO image

To create a VM from .iso, you will use anka create command as you typically would. However, for the .iso file type, you specify an optical drive that mounts the image file into a new VM. You can use the example below, where VMNAME is the name of the VM being created:

$ anka create --optical-drive /path/to/Install_macOS_Sierra.iso VMNAME
Creating VM, please wait...
vm created successfully new uuid: 67044c57-3a65-11e7-84bd-38c98630393f
Would you like to start the new vm? [y/N]: y
+-----------------------+--------------------------------------+
| uuid                  | 67044c57-3a65-11e7-84bd-38c98630393f |
+-----------------------+--------------------------------------+
| name                  | VMNAME                               |
+-----------------------+--------------------------------------+
| cpu_cores             | 2                                    |
+-----------------------+--------------------------------------+
| ram                   | 2G                                   |
+-----------------------+--------------------------------------+
| image_id              | 48c8cb23-3a65-11e7-a2cb-38c98630393f |
+-----------------------+--------------------------------------+
| status                | running                              |
+-----------------------+--------------------------------------+
| vnc_port              | 5904                                 |
+-----------------------+--------------------------------------+
| vnc_connection_string | vnc://:admin@xxx.xxx.xx.xxx:5904     |
+-----------------------+--------------------------------------+
| vnc_password          | admin                                |
+-----------------------+--------------------------------------+
| view_vm_display       | anka view VMNAME                     |
+-----------------------+--------------------------------------+

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:

# Remove the existing optical drive with the .iso installer
anka modify VMNAME delete optical-drive 0

# Add new optical drive with paravirtual driver installer image
anka modify VMNAME add optical-drive --file /Library/Application\ Support/Veertu/Anka/guestaddons/anka-addons-mac.iso

Then, start and view the VM using the commands below:

# Start the VM
anka start VMNAME

# View the VM in the Anka Viewer application
anka view VMNAME

Install the guest add-ons inside the VM. Close the Anka Viewer and execute the following commands:

# Stop the VM
anka stop VMNAME

# Remove the Guest Add-ons drive
anka modify VMNAME delete optical-drive 0

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.