Skip to content
Matt Churchyard edited this page Jul 16, 2016 · 8 revisions

vm-bhyve 1.1 now contains support for multiple datastores. There is also a new set of commands for managing these.

Basic configuration works as normal. You create a directory or ZFS dataset for your vm-bhyve configuration and guests to use. This is set in /etc/rc.conf as normal.

vm_dir="zfs:sys/data/vm"

When running vm-bhyve, this directory is used for ISO files and core configuration data. This also becomes the default datastore for virtual machines. If you list datastores, you will see this displayed.

# vm datastore list
NAME            TYPE        PATH                      ZFS DATASET
default         zfs         /data/vm                  sys/data/vm

This shows the name, type and filesystem path for the datastore. For ZFS stores, it also shows the dataset name.

New datastores can be added using the # vm datastore add <name> <spec> command. The name must be a string of letters, numbers and -. characters up to 16 chars in length. Just like vm_dir in /etc/rc.conf, the datastore spec should either be a directory path, or zfs:pool/dataset. Please note that we do not create the directory or dataset for you, it should already exist.

# vm datastore add ssd zfs:sys/data/vm2
# vm datastore list
NAME            TYPE        PATH                      ZFS DATASET
default         zfs         /data/vm                  sys/data/vm
ssd             zfs         /data/vm2                 sys/data/vm2

A datastore can be removed using the # vm datastore remove <name> command. The datastore is only removed from configuration, any data is left in place.

When creating virtual machines, they will be created on the default datastore. However you can specify another datastore using the -d option

# vm create -d ssd -t centos7 -s 50G centos-ssd

The list and info commands have also been updated to display datastore information.

# vm list
NAME            DATASTORE       LOADER      CPU    MEMORY    AUTOSTART    STATE
alpine          default         grub        1      512M      No           Stopped
centos          default         grub        1      512M      Yes [1]      Stopped
wintest         default         none        2      2G        No           Running (15087)
fb2             ssd             bhyveload   1      256M      No           Stopped
#
# vm info fb2
------------------------
Virtual Machine: fb2
------------------------
  state: stopped
  datastore: ssd
....

Please note that guest names are still required to be unique across all datastores. If multiple guests with the same name exist (for instance if you add a datastore that already contains guests), any vm-bhyve commands will search datastores in the order they were added, and only operate on the first one found.