Modifying your VM

Modify your VM using the Anka Virtualization CLI

Prerequisites

  1. You’ve installed the Anka Virtualization package
  2. You’ve created your first VM

The rest of this Getting Started guide focuses heavily on the (Command-Line Interface). These will be performed from within your macOS Terminal. For all available CLI commands, flags, and options, see the Command Reference.
> anka modify --help
usage: modify vmid <command>

   Modify a VM parameters

arguments:
  vmid                     Virtual machine to modify

commands:
  add                      Add new items to a VM configuration
  delete                   Remove items from a VM configuration
  name                     Set new name for the VM
  cpu                      Set number of vcpu cores and frequency
  ram                      Set RAM size and parameters
  network                  Modify network card settings
  port                     Add port forwarding rule
  disk                     Modify hard drive settings
  display                  Configure displays
  label                    Assign labels to a VM in key/value form

Mac mini (M1, 2020, 8-core/4-performance + 4-efficiency, 8 or 16GB RAM)

  • 1VM (recommended) - CPUs: 6-cores & RAM: ( totalRAMGB - 2GB )
  • 2VMs (not recommended) - CPUs: 4-cores & RAM: ( (totalRAMGB / 2) - 2GB )

Mac Studio (M1 Max, 2022, 10-core/8-performance + 2-efficiency, 32 or 64GB RAM)

  • 1VM - CPUs: 8-cores & RAM: ( totalRAMGB - 2GB ) with a max of 60GBs
  • 2VMs - CPUs: 6,8-cores & RAM: ( (totalRAMGB / 2) - 2GB ) with a max of 60GBs

Mac Studio (M1 Ultra, 2022, 20-core/16-performance + 4-efficiency, 64 or 128GB RAM)

  • 1VM - CPUs: 8-cores & RAM: ( totalRAMGB - 2GB ) with a max of 60GBs
  • 2VMs - CPUs: 8-cores & RAM: ( (totalRAMGB / 2) - 2GB ) with a max of 60GBs
Due to Ultra using the NUMA architecture, VMs/virtualization will only ever use 8 performance cores at a time.

Common Examples

VM Resources

CPU

> anka modify 13.0.1-arm64 cpu --help
usage: cpu [options] [vcpu]

   Set number of vcpu cores and frequency

arguments:
  vcpu                     Number of vcpu cores

options:
  -c,--cores <val>         Number of vcpu cores
  -f,--frequency <val>     Set the base vcpu frequency (Hz)
❯ anka show 12.6 cpu
+-------+---+
| cores | 4 |
+-------+---+

❯ anka modify 12.6 cpu 5

❯ anka show 12.6 cpu
+-------+---+
| cores | 5 |
+-------+---+

RAM

> anka modify 13.0.1-arm64 ram --help
usage: ram [size]

   Set RAM size and parameters

arguments:
  size                     Size of RAM (supported suffixes: T|G|M|K)
❯ anka show 12.6 ram
+------+------+
| size | 4GiB |
+------+------+

❯ anka modify 12.6 ram 6G

❯ anka show 12.6 ram     
+------+------+
| size | 6GiB |
+------+------+

DISK

> anka modify 13.0.1-arm64 disk --help
usage: disk [options]

   Modify hard drive settings

options:
  -c,--controller <val>    set controller: sata/virtio-blk
  -s,--size <val>          set disk size (supported suffixes: T|G|M|K)
  -f,--file <val>          assign external image or device
  --ro                     mark the image as read-only for the VM
  --rw                     mark the image as writable (default) for the VM
When resizing the VM’s disk, you must also execute diskutil apfs resizeContainer disk0s2 0 inside of the VM.
❯ anka show 12.6 disk size
128GiB

❯ anka modify 12.6 disk -s 200G

❯ anka run 12.6 bash -c "df -h"
Filesystem       Size   Used  Avail Capacity iused      ifree %iused  Mounted on
/dev/disk2s1s1  123Gi   14Gi  106Gi    12%  502068 1106561040    0%   /

❯ anka run 12.6 bash -c "diskutil apfs resizeContainer disk0s2 0"
Started APFS operation
Aligning grow delta to 77,309,411,328 bytes and targeting a new physical store size of 208,855,367,680 bytes
Determined the maximum size for the targeted physical store of this APFS Container to be 208,855,370,752 bytes
Resizing APFS Container designated by APFS Container Reference disk2
The specific APFS Physical Store being resized is disk0s2
Verifying storage system
Using live mode
Performing fsck_apfs -n -x -l /dev/disk0s2
Checking the container superblock
. . .
Verifying volume object map space
The volume /dev/rdisk2s6 appears to be OK
Verifying allocated space
The container /dev/disk0s2 appears to be OK
Storage system check exit code is 0
Growing APFS Physical Store disk0s2 from 131,545,956,352 to 208,855,367,680 bytes
Modifying partition map
Growing APFS data structures
Finished APFS operation

❯ anka run 12.6 bash -c "df -h"
Filesystem       Size   Used  Avail Capacity iused      ifree %iused  Mounted on
/dev/disk2s1s1  195Gi   14Gi  177Gi     8%  502068 1860793720    0%   /

Port forwarding from guest to host

> anka modify 13.0.1-arm64 port --help
usage: port [options] name [rule]

   Add port forwarding rule

arguments:
  name                     Rule name
  rule                     Port forwarding rule: guest-port[:host-ip][:host-port]

options:
  -g,--guest-port <val>    The port inside of the VM that the host-port connects to
  -p,--host-port <val>     The host port to listen on (assigns dynamically if not specified)
  -l,--host-ip <val>       Listen address (defaults to any)
  -d,--delete              Delete the rule
  --set-name <val>         Rename the rule
❯ anka modify 12.6 port --help
usage: port [options] name [rule]

   Add port forwarding rule

arguments:
  name                     Rule name
  rule                     Port forwarding rule: guest-port[:host-ip][:host-port]

options:
  -g,--guest-port <val>    The port inside of the VM that the host-port connects to
  -p,--host-port <val>     The host port to listen on (assigns dynamically if not specified)
  -l,--host-ip <val>       Listen address (defaults to any)
  -d,--delete              Delete the rule
  --set-name <val>         Rename the rule

❯ anka modify 12.6 port test 22:0.0.0.0:50022

❯ anka show 12.6 network
. . .
port_forwarding_rules:
+------+----------+------------+-----------+
| name | protocol | guest_port | host_port |
+------+----------+------------+-----------+
| test | tcp      | 22         | 50022     |
+------+----------+------------+-----------+

❯ anka start 12.6

❯ ssh anka@localhost -p 50022
(anka@localhost) Password:
Last login: Fri Oct 14 06:37:54 2022
anka@Ankas-Virtual-Machine ~ % 

Changing your VM’s network configuration

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:

> anka modify 13.0.1-arm64 network --help
usage: network [options]

   Modify network card settings

options:
  -t,--mode <val>          network mode: shared/host/bridge/disconnected
  -b,--bridge <val>        host interface name to bridge with in the bridge mode, or "auto"
  -m,--mac <val>           specify fixed MAC address, or "auto"
  -v,--vlan <val>          assign VLAN ID, 0 to deassign
  -c,--controller <val>    set controller: anet, virtio-net
  --local                  enable (default) inter-VM and VM-host communication
  --no-local               disable inter-VM and VM-host communication
TypeDescription
sharedThe default network type operating as NAT + DHCP. Every VM after the start/resume gets an IP address assigned by the internal DHCP server in range 192.168.64.2 - 192.168.64.254. Programs inside a VM can access external networks (outside the host) and the internet directly. Also, other VMs on the host are also accessible.
host
Not currently supported.
bridgeThe Bridged type will cause the VM to show in the network as an individual device and receive a unique IP separate from the host.
An ENV is available to set the interface name: ANKA_BRIDGE_NAME=en0
When using the bridge, port-forwarding is not necessary as the VM will receive a unique IP that will be accessible directly to all other devices on the network.
By default, DHCP will not see your VM’s MAC address. You’ll need to enable --direct-mac for the network-card: anka modify VmName set network-card 0 --type bridged --direct-mac
You cannot use bridged networking over Wifi.
disconnectedThe VM will have a disconnected network cable.
❯ anka --machine-readable describe 12.2.0-arm | jq '.body.network_cards'
[
  {
    "type": "virtio-net",
    "mode": "shared",
    "port_forwarding_rules": [
      {
        "name": "ssh",
        "protocol": "tcp",
        "guest_port": 22
      }
    ]
  }
]

❯ anka modify 12.2.0-arm network --mode bridge

❯ anka --machine-readable describe 12.2.0-arm | jq '.body.network_cards'
[
  {
    "mode": "bridge",
    "controller": "virtio-net"
  }
]

What’s next?