Modifying your VM Template

Modify your VM Template using the Anka Virtualization CLI

Prerequisites

  1. You've installed the Anka Virtualization package
  2. You've got an active license
  3. You've created your first VM Template

The rest of this Getting Started guide focuses heavily on the Anka Virtualization CLI (Command-Line Interface). These will be performed from within your macOS Terminal. For all available CLI commands, flags, and options, see the Command Reference.

> sudo anka modify --help
Usage: anka modify [OPTIONS] VM_ID COMMAND [ARGS]...

  Modify a VM's configuration

Options:
  --help  Display usage information

Commands:
  add
  delete
  set
  show
> sudo anka modify 11.2.3 set --help
Usage: anka modify set [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Display usage information

Commands:
  cpu              Set number of cpu cores and frequency
  custom-variable  Set custom nvram & smb variables (Example: .
  description      Set description of the VM
  display          Configure displays
  hard-drive       Modify hard drive settings
  name             Set new template name for the VM
  network-card     Modify network card settings
  policy           Enable VM access management
  ram              Set RAM size and parameters

Increase your VM's disk space with hard-drive

Change the disk space on an existing VM with the following commands:

anka modify {vmNameOrUUID} set hard-drive --size 100GB
anka run --no-volume {vmNameOrUUID} diskutil apfs resizeContainer disk1 0

It's currently impossible to downsize a VM's hard-drive. We suggest creating your initial VM Template with a smaller amount of available disk and then increase in subsequent Tags.

Changing your VM's network configuration with network-card

Depending on your network topology, there are instances where you might need to use a bridge mode and assign your VM a unique IP address instead of the default shared IP of the host:

> sudo anka modify 11.2.3 set network-card --help
Usage: anka modify set network-card [OPTIONS] [INDEX]...

  Modify network card settings

Options:
  -t, --type [shared|host|bridge|disconnected]
  -b, --bridge TEXT               host interface name to bridge with
  -m, --mac TEXT                  specify fixed MAC address
  -n, --no-mac                    deassign fixed MAC address
  --direct-mac                    expose --mac externally
  --no-direct-mac                 do not expose --mac externally
  -v, --vlan INTEGER              assign VLAN ID
  -c, --controller [anet|virtio-net]
                                  set controller
  --local / --no-local            enable (default)/disable inter-VM and VM-host communication
  --help                          Display usage information

WiFi interfaces are not supported yet

❯ anka describe 11.0.1
. . .
network_cards

+------------+--------+--------+-----------+
|   pci_slot | type   | mode   |    pci_id |
+============+========+========+===========+
|         28 | anet   | shared | 538975646 |
+------------+--------+--------+-----------+
. . .

❯ anka modify 11.0.1 set network-card 0 -t bridge

❯ anka describe 11.0.1
. . .
network_cards

+------------+--------+--------+-----------+
|   pci_slot | type   | mode   |    pci_id |
+============+========+========+===========+
|         28 | anet   | bridge | 538975646 |
+------------+--------+--------+-----------+
. . .

Set up your VM for external access with port-forwarding

If you wish for the VM to be accessible to other machines on your network, and are using a Shared network mode (the default), you will need to setup port forwarding:

❯ sudo anka modify 10.15.4 add port-forwarding --guest-port 22 ssh

❯ sudo anka describe 10.15.4

. . .

port_forwarding_rules

+------------+--------------+-------------+------------+-----------+-------------+
|   net_card |   guest_port | rule_name   | protocol   |   host_ip |   host_port |
+============+==============+=============+============+===========+=============+
|          0 |           22 | ssh         | tcp        |         0 |           0 |
+------------+--------------+-------------+------------+-----------+-------------+

❯ sudo anka start 10.15.4
. . . 
port_forwarding

+--------------+-------------+------------+--------+-----------+
|   guest_port |   host_port | protocol   | name   | host_ip   |
+==============+=============+============+========+===========+
|           22 |       10000 | tcp        | ssh    | 0.0.0.0   |
+--------------+-------------+------------+--------+-----------+

❯ ssh anka@localhost -p 10000
Password:
Last login: Mon Apr  6 12:45:50 2020
Mac-mini:~ anka

The VM can then be accessed using: ssh anka@{theHostRunningTheVMsIP} -p {host_port}

Unless you customize the host_port (with anka config portfwd_base), we default to using the 10000-10XXX port range. If you start a VM it will get 10000 unless a VM already exist. The existing VM using the 10000 port will cause an automatic assignment of 10001 to the newly started VM. Ensure that both the Controller server and any CI servers (where you host Jenkins for example) can reach the Node's ports in your firewall rules.

Modify the hardware UUID and Serial with custom-variable

At times you might need to modify the hardware serial or UUID to run proper builds/tests that require specific hardware to function properly:

> sudo anka modify 11.2.3 set custom-variable --help
Usage: anka modify set custom-variable [OPTIONS] KEY VALUE

  Set custom nvram & smb variables (Example: . . . set custom-variable hw.serial "<SERIAL>"

Options:
  --help  Display usage information
sudo anka modify {vmNameOrUUID} set custom-variable hw.uuid "GUID"
sudo anka modify {vmNameOrUUID} set custom-variable hw.serial 'MySerial'


What's next?


Last modified April 28, 2021 : removed faqs from guides section (36b5a06) by Nathan Pierce