Disk image files as data memory for virtual hard disks

Disk image files are regular files in which the contents of virtual hard disks can be stored. An empty disk image file of maximum 20 GB can be created with the help of truncate(1) as follows:

truncate -s 20G /vms/samplevm/disk0.img

The created disk0.img file can then be passed to the bhyve call as a backend for a virtual hard disk:

doas bhyve \
-c sockets=1,cores=2,threads=1 \
-m 2G \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_BHF_UEFI.fd \
-s 0,hostbridge \
-s 10,nvme,/vms/samplevm/disk0.img \
-s 31,lpc \
-H -P -A \
samplevm