By Kenneth Bernholm
Bhyve (pronounced "beehive") is the BSD Hypervisor initially written for FreeBSD and later ported to other Unices. The bhyve page on the FreeBSD wiki answers practically all questions you may have, and the FreeBSD Handbook's bhyve section covers all the practical details. This page is merely a quick summary and guide to get going with vm-bhyve managing the Virtual Machines (VMs).
Install, enable, and initialize bhyve:
pkg install vm-bhyve
./etc/rc.conf
by adding vmm_enable="YES"
and vm_dir="{your bhyve folder}"
.kldstat
to verify that your kernel has vmm.ko
loaded. If not, add vmm_load="YES"
to /boot/loader.conf
.pkg install grub2-bhyve
.vm init
.If needed, enable networking for your guests:
vm switch create public
.ifconfig
.vm switch add public {interface}
.Create a guest virtual machine (VM) configured for Debian (why not?) named vdeb1 from the Debian template in /usr/local/share/examples/vm-bhyve/
:
debian.conf
template to {your bhyve folder}/.templates/
.
vm create -t debian vdeb1
.Installing the guest operating system ought to be one procedure, but a couple of small pre- and post procedures are presently required:
pkg install tmux
.console="tmux"
to {your bhyve folder}/.config/system.conf
.{your bhyve folder}/.iso/
with vm iso https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.1.0-amd64-netinst.iso
.vm install vdeb1 debian-12.1.0-amd64-netinst.iso
.vm console vdeb1
.vm stop vdeb1
.console="tmux"
from {your bhyve folder}/.config/system.conf
.Someday the pre- and post installation procedures will become unnecessary. Patience is a virtue.
Type vm help
for a list of commands to managing your VMs:
vm list
.vm start {name of VM}
.vm stop {name of VM}
.vm reset {name of VM}
.~.
(or ~
followed by Ctrl+D). If this fails to work, you have probably forgotten to disable the terminal multiplexer. Stop the VM and fix it.To run X11 applications on a VM, you must set up forwarding of the VM X11 client to the host X11 server.
This procedure configures the host and a FreeBSD VM. For other VMs such as Debian, change the paths and commands as needed.
xhost +inet:{VM ip address}
.pkg install xorg
./etc/ssh/sshd_config
, add
X11Forwarding yes X11UseLocalhost yes
To launch an X11 application on the VM:
ssh {VM ip address} -X
.