Creating VMs

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

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-disk lets you create an empty disk to prepare for an operating system installation. However, you can pass additional arguments that will automatically install the operating system for you. Make sure you have at least 60GB available on the machine.

$ anka create-disk --help
Usage: anka create-disk [OPTIONS]

  creates an empty disk with unique name

Options:
  -s, --size TEXT  new disk size  [default: 60G; optional]
  -a, --app TEXT   Path to Install macOS application (downloadable from
                   AppStore)  [optional]
  -p, --pkg PATH   Additional package to be installed  [optional]
  --help           Show this message and exit.  [optional]

An example is below:

$ anka create-disk --size 40G --app /Applications/Install\ macOS\ Sierra.app/
Installing operating system on 80d39bc0-3941-11e7-8eed-3c15c2d440ca (this could take about half hour)...
disk 80d39bc0-3941-11e7-8eed-3c15c2d440ca created successfully at: 80d39bc0-3941-11e7-8eed-3c15c2d440ca.img

Preparing the VM

Now that our image is created, we can start using this image as a VM by converting it. First, let’s list our images:

$ anka list-images
list of images
+------------+------------------------------------------------------+--------------------------------------+
|       size | vms                                                  | image-id                             |
+============+======================================================+======================================+
| 8279724032 |                                                      | 80d39bc0-3941-11e7-8eed-3c15c2d440ca |
+------------+------------------------------------------------------+--------------------------------------+
| 9556910080 | anka-mactest2 (a9bab60c-3612-11e7-8dc5-3c15c2d440ca) | e4711c0c-360d-11e7-a075-3c15c2d440ca |
+------------+------------------------------------------------------+--------------------------------------+

Note that our new image does not yet have a name. Let’s go ahead and use its image-id to create a VM. We’ve decided to also use --ram-size and --cpu-count to specify some more specifications for this VM:

$ anka create --image-id 80d39bc0-3941-11e7-8eed-3c15c2d440ca --ram-size 2G --cpu-count 2 anka-mactest3
Creating VM, please wait...
vm created successfully new uuid: 8dc38a59-3945-11e7-a2a7-3c15c2d440ca
Would you like to start the new vm? [y/N]: n

Note that we did not choose to start the VM when prompted. If we list our current VMs, we can now see anka-mactest3 in the list:

$ anka list-images
list of images
+------------+------------------------------------------------------+--------------------------------------+
|       size | vms                                                  | image-id                             |
+============+======================================================+======================================+
| 8279724032 | anka-mactest3 (8dc38a59-3945-11e7-a2a7-3c15c2d440ca) | 80d39bc0-3941-11e7-8eed-3c15c2d440ca |
+------------+------------------------------------------------------+--------------------------------------+
| 9556910080 | anka-mactest2 (a9bab60c-3612-11e7-8dc5-3c15c2d440ca) | e4711c0c-360d-11e7-a075-3c15c2d440ca |
+------------+------------------------------------------------------+--------------------------------------+

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           |
+-----------------------+--------------------------------------+

Including setup packages at VM creation

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

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

During the macOS installation process, select My computer does not connect to internet on the How Do you Connect screen. The VM will be automatically configured with Anka PV network driver, after installing guest add-ons.

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.

About macOS High Sierra (beta)

It is possible to create Anka VMs running macOS High Sierra (beta) version. First, download Install macOS 10.13 Beta.app from the Apple Developer portal.

Use anka create-disk to create a High Sierra VM.

This version of the macOS installer prevents auto install/load of third party signed drivers. These drivers need to be explicitly enabled after the VM is created. Hence, just using Anka create-disk & create methods to create VM is not enough. After creating the VM, you will need to do additional setup to enable Anka PV drivers. We are investigating this further and will introduce more user-friendly approach for driver setup in the next Anka Beta update.

Preparing the VM

anka create-disk --size 40G --app ~/Desktop/Install\ macOS\ 10.13\ Beta.app/
Installing operating system on 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59 (this could take about half hour)...
disk 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59 created successfully at: 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59.img

After the disk is created, use the image ID for the VM creation step:

anka create --image-id 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59 --ram-size 2G --cpu-count 2 hisierra

Creating VM, please wait...
vm created successfully with uuid: d76e35e3-4bca-11e7-a506-acbc32ad1d59
Would you like to start the new vm? [y/N]: y
+-----------------------+--------------------------------------+
| uuid                  | d76e35e3-4bca-11e7-a506-acbc32ad1d59 |
+-----------------------+--------------------------------------+
| name                  | hisierra                             |
+-----------------------+--------------------------------------+
| cpu_cores             | 2                                    |
+-----------------------+--------------------------------------+
| ram                   | 2G                                   |
+-----------------------+--------------------------------------+
| image_id              | 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59 |
+-----------------------+--------------------------------------+
| status                | running                              |
+-----------------------+--------------------------------------+
| vnc_port              | 5900                                 |
+-----------------------+--------------------------------------+
| vnc_connection_string | vnc://:admin@xx.x.x.x:5900           |
+-----------------------+--------------------------------------+
| vnc_password          | admin                                |
+-----------------------+--------------------------------------+
| view_vm_display       | anka view hisierra                   |
+-----------------------+--------------------------------------+

Then, view the new High Sierra VM in the ankaview application:

anka view hisierra

Manually install the guest add-ons

Complete the macOS setup steps.

You may see a prompt to allow the ‘Veertu Inc.’ extension to be enabled. Click OK, then go to System Preferences > Security and Privacy and Allow this extension.

Then reboot the VM from inside and stop and start the VM to pick up the changes. After the VM has started, run anka view again to bring up the viewer.

anka stop hisierra
anka start hisierra
+-----------------------+--------------------------------------+
| uuid                  | d76e35e3-4bca-11e7-a506-acbc32ad1d59 |
+-----------------------+--------------------------------------+
| name                  | hisierra                             |
+-----------------------+--------------------------------------+
| cpu_cores             | 2                                    |
+-----------------------+--------------------------------------+
| ram                   | 2G                                   |
+-----------------------+--------------------------------------+
| image_id              | 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59 |
+-----------------------+--------------------------------------+
| status                | running                              |
+-----------------------+--------------------------------------+
| vnc_port              | 5900                                 |
+-----------------------+--------------------------------------+
| vnc_connection_string | vnc://:admin@xx.x.x.x:5900           |
+-----------------------+--------------------------------------+
| vnc_password          | admin                                |
+-----------------------+--------------------------------------+
| view_vm_display       | anka view hisierra                   |
+-----------------------+--------------------------------------+

anka view hisierra

When you run anka run for the first time on High Sierra VM, you will see a prompt to allow the ‘osxfuse Benjamin Fleischer’ extension to be enabled. Click OK, then go to System Preferences and then go to Security and Privacy and allow this extension.

Then reboot the VM from inside and anka stop and anka start the VM to pick up the changes. After the VM has started, run anka view again to bring up the viewer.

anka stop hisierra
anka start hisierra
+-----------------------+--------------------------------------+
| uuid                  | d76e35e3-4bca-11e7-a506-acbc32ad1d59 |
+-----------------------+--------------------------------------+
| name                  | hisierra                             |
+-----------------------+--------------------------------------+
| cpu_cores             | 2                                    |
+-----------------------+--------------------------------------+
| ram                   | 2G                                   |
+-----------------------+--------------------------------------+
| image_id              | 098a62dc-4bc8-11e7-8bf8-acbc32ad1d59 |
+-----------------------+--------------------------------------+
| status                | running                              |
+-----------------------+--------------------------------------+
| vnc_port              | 5900                                 |
+-----------------------+--------------------------------------+
| vnc_connection_string | vnc://:admin@xx.x.x.x:5900           |
+-----------------------+--------------------------------------+
| vnc_password          | admin                                |
+-----------------------+--------------------------------------+
| view_vm_display       | anka view hisierra                   |
+-----------------------+--------------------------------------+

Verifying High Sierra (beta) VM setup

Verify that all Anka PV drivers and Guest add-ons loaded successfully. From your mac/host execute following command:

anka run hisierra ls -l

If it displays the contents of your current VM folder, then your High Sierra(beta) VM setup is complete.

Next Steps

You can continue the setup of your macOS VM environment normally to prepare it for usage for development. The VM can also be uploaded to Anka Registry for distribution and versioning.