Skip to main content.

Virtualization with bhyve


Live demo in BSD Now Episode 020 | Originally written by Allan for, with minor edits | Last updated: 2014/01/15

NOTE: the author/maintainer of the tutorial(s) is no longer with the show, so the information below may be outdated or incorrect.

Virtualization has been a hot topic for a while now, and there are lots of options for it. On FreeBSD, there's the often-copied jail feature. For a lot of use cases, that's ideal. There's no overhead, they're very secure and they offer supreme flexibility. However, sometimes people need to use other operating systems. You could use a userland application like VirtualBox, but performance leaves something to be desired. There are times when performance needs to be at the top of the list. For those times, you'll need something else.

You'll need bhyve.

Short for the BSD Hypervisor, bhyve is a great virtualization technology in the vein of Xen or KVM, but done BSD style and without legacy support. It's a type 2 hypervisor that lets you run other operating systems under FreeBSD. It was officially released in FreeBSD 10.0. So enough talking, let's get it set up. Keep in mind that bhyve requires an Intel CPU with VT-x and Extended Page Table support.


Start off by creating a disk image to use for the VM. We'll use a 10GB file.

# truncate -s 10g bhyve1.img

Load the bhyve kernel module.

# kldload vmm

Create a bridge and your tap network interface.

# ifconfig bridge0 create
# ifconfig tap0 create
# sysctl

Add your LAN interface and the tap interface to the bridge. The NIC is called igb0 in this case.

# ifconfig bridge0 addm igb0 addm tap0
# ifconfig bridge0 up

Download a copy of FreeBSD to install.

# fetch

Copy the template bhyve script. (Official Instructions)

# cp /usr/share/examples/bhyve/
# chmod +x

Configure the number of CPUs, amount of ram, name of disk image.

# vi

Start bhyve in installation mode.

# ./ -i -I FreeBSD-10.0-RC5-amd64-bootonly.iso fbsd10

Do an install as usual, but at the end, choose to enter a shell on the installed system. Because bhyve does not emulate a graphics card, only a serial console, we need to configure the system to boot with the serial console.

# vi /etc/ttys

Change this line:

console none    unknown off secure

To the following:

console "/usr/libexec/getty std.9600"    xterm   on  secure

Now, restart the vm, and choose reboot from the beastie menu to exit.

# reboot

Rebooting exits bhyve, so lets start it again without the install disk.

# ./ fbsd10

You now have a working FreeBSD in bhyve.

# reboot

Select reboot, or hit ESC and type quit, from the beastie menu to exit. The vmrun script tries to keep your vm running so restarts it when it crashes/exits.


This requires the grub2-bhyve port. Install it via ports or pkgng. Create an OpenBSD tap device and add it to the bridge

# ifconfig tap1 create
# ifconfig bridge0 addm tap1

Download this working OpenBSD image:

# fetch
# bunzip2 flashimg.amd64-20131014.bz2

Create a grub device map,, containing:

(hd0) ./obsd.img
Booting the OpenBSD image:
grub-bhyve -m -r hd0 -M 512 obsd

This will start grub, enter the following:

kopenbsd -h com0 (hd0,openbsd1)/bsd

Start bhyve

# bhyve -c 2 -m 512M -A -H -P -s 0:0,amd_hostbridge -s \
  1:0,lpc -s 2:0,virtio-net,tap1 -s 3:0,virtio-blk,obsd.img -l com1,stdio -W obsd

The image may fail to boot because it was shutdown improperly, restarting it should resolve this. The root password is: test123

Clean up the VM:

# bhyvectl --destroy --vm=obsd

This tutorial is ongoing and will be updated at a later time to include autostarting.

Latest News

Two Year Anniversary


We're quickly approaching our two-year anniversary, which will be on episode 105. To celebrate, we've created a unique t-shirt design, available for purchase until the end of August. Shirts will be shipped out around September 1st. Most of the proceeds will support the show, and specifically allow us to buy...

New discussion segment


We're thinking about adding a new segment to the show where we discuss a topic that the listeners suggest. It's meant to be informative like a tutorial, but more of a "free discussion" format. If you have any subjects you want us to explore, or even just a good name...

How did you get into BSD?


We've got a fun idea for the holidays this year: just like we ask during the interviews, we want to hear how all the viewers and listeners first got into BSD. Email us your story, either written or a video version, and we'll read and play some of them for...

EuroBSDCon 2014


As you might expect, both Allan and Kris will be at EuroBSDCon this year. They'll be busy hunting down various BSD developers and forcing them to do interviews, but don't hesitate to say hi if you're a listener!...

Episode 164: Virtualized COW / PI?


Direct Download:VideoHD VideoMP3 AudioOGG AudioTorrent This episode was brought to you by Headlines vmm enabled VMM, the OpenBSD hypervisor, has been imported into current It has similar hardware requirements to bhyve, a Intel Nehalem or newer CPU with the hardware virtualization features enabled in the BIOS AMD support has not been started yet OpenBSD is the...

Episode 163: Return of the Cantrill


Direct Download:VideoHD VideoMP3 AudioOGG AudioTorrent This episode was brought to you by Headlines FreeBSD 11.0-RELEASE Now Available FreeBSD 11.0-RELEASE is now officially out. A last minute reroll to pickup OpenSSL updates and a number of other security fixes meant the release was a little behind schedule, and shipped as 11.0-RELEASE-p1, but the release is better...

Episode 162: The Foundation of NetBSD


Direct Download:VideoHD VideoMP3 AudioOGG AudioTorrent This episode was brought to you by Headlines What is new on EC2 for FreeBSD 11.0-RELEASE “FreeBSD 11.0-RELEASE is just around the corner, and it will be bringing a long list of new features and improvements — far too many for me to list here. I think there are...

Episode 161: The BSD Bromance


Direct Download:VideoHD VideoMP3 AudioOGG AudioTorrent This episode was brought to you by Headlines EuroBSDCon 2016 Wrapup Ollivier Robert’s Photos from EuroBSDCon Get your BSDNow die-cut stickers NetBSD for newbies - Develop your own Power PC We don’t get to feature too many stories on NetBSD being deployed as a Power PC (Not PowerPC, you...