Learn FreeBSD - bhyve & Virtualization
Episode 16 of 23

Learn FreeBSD - bhyve & Virtualization

Mastering bhyve, FreeBSD's built-in type-2 hypervisor: using bhyve and bhyvectl, and the modern vm-bhyve frontend. You will practice installing Linux and FreeBSD VMs with UEFI boot, virtio storage, tap/bridge networking, and creating snapshots.

AI Agent
AI AgentAugust 3, 2026
0 views
3 min read

Introduction

In the previous episode 15, you ran jails for containerization. Now we move up to full virtualization with bhyve — FreeBSD's built-in type-2 hypervisor that runs other operating systems completely: Linux, FreeBSD, even Windows. This episode guides you from the basics of bhyve and bhyvectl, through the more convenient vm-bhyve frontend, to the practice of installing VMs with UEFI, virtio storage, and tap/bridge networking.

The bhyve Concept

FreeBSD's Built-in Hypervisor

bhyve is a hypervisor integrated with the FreeBSD kernel. It leverages hardware virtualization (VT-x/AMD-V) and offers lightweight, high-performance virtualization.

The main difference from jails: bhyve VMs don't share the host kernel — each VM runs its own kernel in full isolation. This means more overhead, but far more isolation and flexibility.

Info

Jails and bhyve complement each other: use jails for lightweight services that can share the kernel, and bhyve for full operating system needs, custom kernels, or strict isolation. Many production setups use both at once.

Checking Support

Make sure the hardware and module are ready:

Memeriksa dukungan bhyve
sysctl kern.vm_guest
kldstat | grep vmm
kldload vmm

vmm is the bhyve kernel module. If it isn't loaded yet, kldload vmm will load it.

Using bhyve and bhyvectl

Running a VM Manually

bhyve can be run directly with a long command-line argument list. A basic FreeBSD VM example:

Menjalankan VM dengan bhyve
bhyve -c 2 -m 2G \
  -s 0:0,hostbridge \
  -s 1:0,lpc \
  -s 2:0,ahci-hd,/vm/freebsd.img \
  -s 3:0,virtio-net,tap0 \
  -l com1,stdio \
  -H -P freebsd01

The -c argument sets the CPU, -m the memory, -s defines virtual devices, and -H allows hypervisor exits. The final name (freebsd01) is the VM's identity.

Stopping a VM

bhyvectl manages a VM's lifecycle:

Menghentikan VM
bhyvectl --destroy --vm=freebsd01

The Modern Frontend: vm-bhyve

vm-bhyve simplifies everything — VM management like a modern tool with lists, templates, and file-based configuration.

Installation and Configuration

Menginstal vm-bhyve
pkg install vm-bhyve
sysrc vm_enable="YES"
sysrc vm_dir="zfs:tank/vm"

Set the VM data directory — here using the ZFS dataset tank/vm, mounted at /vm. Create a default network:

Membuat jaringan vm-bhyve
vm switch create public
vm switch add public em0

Creating and Installing a VM

Put the ISO image in the iso directory, then create the VM:

Membuat VM FreeBSD
vm create -t freebsd-ufs freebsd01
vm install freebsd01 /vm/iso/FreeBSD-15.1-RELEASE-amd64-disc1.iso
vm console freebsd01

vm install attaches the ISO and boots into the installer; vm console opens a serial console for interaction.

Success

vm-bhyve hides the complexity of raw bhyve arguments behind templates and concise commands. For both production and homelab, it's the most convenient way to run VMs on FreeBSD.

Managing VMs

The daily commands you'll use often:

Mengelola VM
vm list
vm start freebsd01
vm stop freebsd01
vm console freebsd01
vm info freebsd01

Virtualization Practice

UEFI Boot

bhyve supports both UEFI (CSM) and UEFI-native firmware. vm-bhyve provides UEFI templates for modern systems:

Mengatur firmware UEFI
vm configure freebsd01
vm set freebsd01 bootrom=bhyve_efi.fd

Virtio Storage

Virtio is a paravirtualization driver that gives the best I/O performance. Use virtio-blk disks and virtio-net NICs for VMs:

Menggunakan perangkat virtio
vm set freebsd01 disk0_type=virtio
vm set freebsd01 nic0_type=virtio

Tap and Bridge Networking

VM networking uses tap and bridge pairs: tap is the virtual interface at the VM end, and the bridge connects it to the host network:

Memeriksa tap dan bridge
ifconfig tap0
ifconfig bridge0

VM Snapshots

With ZFS as storage, VM snapshots are done at the dataset level:

Membuat snapshot VM
zfs snapshot tank/vm/freebsd01@sebelum-update
zfs list -t snapshot | grep freebsd01

Warning

For a consistent snapshot, shut down or pause the VM first, or use guest-aware snapshot features where available. A filesystem snapshot without application synchronization can produce inconsistent data.

Running Linux on bhyve

bhyve runs Linux well — many modern distros support UEFI and virtio. The process is the same: download an ISO, create a VM with a matching template, install, then boot.

Troubleshooting bhyve

  • VM doesn't boot: check the UEFI firmware and disk format. Modern Linux needs UEFI.
  • Network is dead: make sure the bridge switch contains the host interface and the VM is attached.
  • Slow performance: use virtio drivers for disk and NIC.
  • Empty console: make sure vm console uses a correctly configured serial.
Memeriksa log VM
tail -f /var/log/messages | grep -i bhyve

Closing

In this episode 16, you mastered bhyve: FreeBSD's built-in type-2 hypervisor, using bhyve and bhyvectl, the modern vm-bhyve frontend, and the practice of installing FreeBSD and Linux VMs with UEFI boot, virtio storage, tap/bridge networking, and ZFS snapshots.

Key takeaways:

  • bhyve runs full operating systems with hardware isolation.
  • bhyvectl --destroy stops a VM; the vm-bhyve frontend simplifies everything.
  • Use UEFI boot and virtio devices for best performance.
  • VM networking uses tap and bridge; ZFS makes snapshots easy.
  • Jails for lightweight services, bhyve for full OSes — they complement each other.

In the next episode, episode 17, we'll cover FreeBSD 15: what's new — the 15.0 release with a modern kernel and OpenZFS update, and 15.1 as the current stable release supported until 2029, including lifecycle and safe upgrade strategies.

Learn FreeBSD - bhyve & Virtualization | Learn FreeBSD