How to Set Up a bhyve Virtual Machine Step by Step
A complete, start-to-finish walkthrough of creating a Linux guest VM under bhyve on FreeBSD, using vm-bhyve to manage the lifecycle.
This walkthrough sets up a complete, working Linux guest under bhyve, using vm-bhyve (the standard higher-level management layer) rather than assembling raw bhyve command lines by hand.
Step 1: install the required packages
pkg install vm-bhyve bhyve-firmware
bhyve-firmware provides the UEFI firmware image needed to boot non-BSD guests like Linux.
Step 2: load the vmm kernel module
kldload vmm
# /etc/rc.conf
vmm_load="YES"
The second line makes this persist across reboots.
Step 3: set up networking
Create a bridge interface joining a tap device to your physical network interface, so guest VMs can reach the network directly:
sysrc cloned_interfaces+="bridge0"
sysrc ifconfig_bridge0="addm em0 SYNCDHCP"
service netif restart
Step 4: initialize vm-bhyve
sysrc vm_enable="YES"
sysrc vm_dir="zfs:zroot/vms"
service vm start
vm init
Using a ZFS dataset (zfs:zroot/vms) for VM storage means each VM’s disk image benefits from ZFS snapshots automatically.
Step 5: fetch a template and create the VM
vm datastore
vm template # lists available templates, e.g. debian.conf, ubuntu.conf
vm create -t debian -s 20G mydebianvm
This creates a new VM named mydebianvm with a 20GB disk, based on the Debian template’s default configuration (CPU count, memory, network device type).
Step 6: install the guest OS
vm iso https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso
vm install mydebianvm debian-12.5.0-amd64-netinst.iso
vm install boots the VM attached to the specified ISO, dropping you into the installer’s console.
Step 7: connect to the installer console
vm console mydebianvm
Complete the Debian installer’s normal steps (partitioning, base system install, package selection) exactly as you would on real hardware — bhyve’s virtual disk and network devices appear to the guest OS as ordinary hardware.
Step 8: reboot into the installed system
Once installation completes and the guest shuts down, start it normally (without the ISO attached this time):
vm start mydebianvm
vm console mydebianvm
Step 9: verify networking from inside the guest
# inside the Debian guest
ip addr show
ping -c3 8.8.8.8
If the guest doesn’t get an address via DHCP, confirm the bridge configuration from step 3 and that the VM’s template specifies a network device attached to bridge0.
Step 10: manage the VM going forward
vm list
vm stop mydebianvm
vm start mydebianvm
vm destroy mydebianvm # when you're actually done with it
Where to go from here
Once this basic setup works, vm-bhyve’s per-VM configuration files (under /zroot/vms/mydebianvm/mydebianvm.conf) let you adjust CPU count, memory, and additional virtual devices directly — and because the VM’s disk lives on a ZFS dataset, zfs snapshot zroot/vms/mydebianvm@before-upgrade gives you an instant, space-efficient rollback point before any risky change inside the guest, exactly the same ZFS snapshot mechanism covered elsewhere on this blog, just applied to a VM’s disk image rather than a regular filesystem.