pkg install bhyve-firmware uefi-edk2-bhyve uefi-edk2-bhyve-csm vm-bhyve

kldload if_bridge if_tap nmdm vmm

echo 'if_bridge_load="YES"' >> /boot/loader.conf
echo 'if_tap_load="YES"' >> /boot/loader.conf
echo 'nmdm_load="YES"' >> /boot/loader.conf
echo 'vmm_load="YES"' >> /boot/loader.conf

echo 'ifconfig_igb1=up' >> /etc/rc.conf.local

sysrc vm_enable="YES"
sysrc vm_dir="zfs:zroot/vms"
sysrc vm_list=""
sysrc vm_delay="5"

zfs create -o mountpoint=/vms zroot/vms

vm init
cp /usr/local/share/examples/vm-bhyve/* /vms/.templates/
vm switch create sw1
vm switch add sw1 igb1
vm iso
vm create -t centos7 -s 100G my_server

Modify the vm config file vm configure my_server:

uuid="<your UUID>"
network0_mac="<your MAC>"
vm install my_server CentOS-7-x86_64-DVD-1804.iso

When you're done, make it auto-start:

sysrc vm_list="my_server"

To access it:

vm console my_server

Finally, if you run into an issue where it can't find the UEFI bootloader, here's what I had to do:

  1. Start the vm: vm start my_server

  2. Let it fail to the UEFI shell.

  3. Type exit and select Boot Maintenance Manager, then Boot from file.

  4. Navigate to your grubx64.efi file and select it.
    Probably here: /boot/efi/EFI/centos/grubx64.efi

  5. Copy the existing grubx64.efi to the location where it's expected:
    cp /boot/efi/EFI/centos/grubx64.efi /boot/efi/EFI/BOOT/

    You'll likely need to repeat these last steps if the .efi file gets updated.