Adding disks to a bhyve vm in SmartOS

To add a disk to a bhyve vm in SmartOS, is pretty easy just run vmadm update with the correct json

{
  "add_disks": [
    {
      "media": "disk",
      "boot": false,
      "nocreate": false,
      "model": "virtio",
      "zfs_filesystem": "zones/d5ad188a-7a73-4aef-a25a-5d9a7a3f7696/disk2",
      "size":  81920
    }
  ]
}

The most import properties here are:

Then finally just, run vmadm update (the vm must be stopped first)

vmadm update <bhyve zone uuid> < add-disk-payload.json

In the case you have this error

first of 1 error: Command failed: cannot create 'zones/df3f4f6a-60df-49fe-ba02-bfc1282213d4/disk2': out of space

you need to increase the zfs quota property to the zones dataset

[root@gandalf /opt/templates]# zfs set quota=240G  zones/df3f4f6a-60df-49fe-ba02-bfc1282213d4
[root@gandalf /opt/templates]# vmadm update df3f4f6a-60df-49fe-ba02-bfc1282213d4  < adddisks2.json
Successfully updated VM df3f4f6a-60df-49fe-ba02-bfc1282213d4
Forest Interior with a Brook (1900–1902) by Unknown artist