Virtual Disks - churchers/vm-bhyve GitHub Wiki
When a guest is created from a template, a disk image is created for each disk specified in the template. If you would like to add disks to a guest after it has been created, you can either use the vm add
command, or create the disk image then update the configuration file manually.
Below are some examples of supported disk configurations
Simple Sparse File
disk0_type="virtio-blk"
disk0_name="disk0.img"
Sparse ZVOL
Non sparse zvols are also supported by just specifying disk0_dev="zvol"
disk0_type="virtio-blk"
disk0_name="disk0"
disk0_dev="sparse-zvol"
Custom Disk
This allows you to specify a custom path to a disk image. The disk could be a sparse
file, a ZVOL, or even a real disk under /dev/
disk0_type="virtio-blk"
disk0_name="/dev/ada10"
disk0_dev="custom"
Simple Sparse File With Options
disk0_type="virtio-blk"
disk0_name="disk0.img"
disk0_opts="nocache,direct"
Custom ZVOL disk
If you would like to attach an additional disk to an existing guest using a ZVOL, follow these instructions.
First of all, create a new ZVOL for the disk image. If you do not want the ZVOL to be sparse, remove the -s
option.
# zfs create -sV 50G -o volmode=dev path/to/dataset/zvol
Then add this as an additional disk to your guest configuration file.
# vm configure myguest
disk1_name="/dev/zvol/path/to/dataset/zvol"
disk1_type="virtio-blk"
disk1_dev="custom"
VirtIO 9p share
This is a configuration example for sharing files/folders with a VM using VirtIO 9p.
First, add the following to the guest configuration file:
# vm configure myguest
disk1_type="virtio-9p"
disk1_name="sharename=/path/to/share"
disk1_dev="custom"
Optionally, append ,ro
to disk1_name
to make it read-only.
On a FreeBSD guest, the 9p share can be mounted with the following command:
# mount -t 9p -o trans=virtio sharename /local/mount/point/of/share
Persistent configuration can be done with fstab(5):
sharename /local/mount/point/of/share 9p trans=virtio,rw 0 0