In /etc.rc.conf:

cloned_interfaces="lo1 bridge0 tap0"
config_lo1="inet 127.0.1.1/8"
autobridge_interfaces="bridge0"
autobridge_bridge0="tap* igb0"
ifconfig_bridge0="addm igb0 addm tap0 up description bhyve"

In /boot/loader.conf:

vmm_load="YES"
nmdm_load="YES"

Check that you have:

sysctl net.link.tap.up_on_open=1

Create the volume:

zfs create -V100G -o volmode=dev tank/ubuntuvm

Install:

pkg install uefi-edk2-bhyve

this will create /usr/local/share/uefi-firmware/BHYVE_UEFI.fd

Setup and install:

bhyve -AHP -w \
-s 1:0,lpc \
-s 2:0,virtio-net,tap0 \
-s 3:0,ahci-cd,/tank/iso/ubuntu-20.04.2-live-server-amd64.iso \
-s 4:0,virtio-blk,/dev/zvol/tank/ubuntuvm \
-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-c 4 -m 8G ubuntu

Install when ask to reboot, destroy the vm:

bhyvectl --destroy --vm=ubuntu

Then to start just remove the CD ahci-cd:

while true; do
bhyve -AHP -w \
-s 1:0,lpc \
-s 2:0,virtio-net,tap0 \
-s 4:0,virtio-blk,/dev/zvol/tank/ubuntuvm \
-s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
-c 4 -m 8G ubuntu
bhyve_exit=$?
if [ $bhyve_exit -ne 0 ]; then
    break
fi
done
/usr/sbin/bhyvectl --destroy --vm=ubuntu

🔗debian

Boot using EFI file grupx64.efi then:

cp /boot/efi/EFI/debian/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi

To connect using the VNC client you can install it using this cask:

brew install --cask vnc-viewer

More info:

  • https://docs.freebsd.org/doc/13.0-RELEASE/usr/local/share/doc/freebsd/handbook/virtualization-host-bhyve.html
  • https://www.cyberciti.biz/faq/how-to-install-linux-vm-on-freebsd-using-bhyve-and-zfs/