Building BHyVe HOWTO

Caution

What I describing in this text is not so different with FreeBSD official manual, if you haven't read official manual you should read it first.
Here's the link:
23.6. Rebuilding World

Install FreeBSD 9.0/amd64.

We won't use src or ports in this document.
You can unselect all extra components if you wish.

Note: You CANNOT use i386 version. It has to amd64.

Install Subversion, checkout BHyVe development branch.

su -
cd /root
pkg_add -r subversion
svn co svn://svn.freebsd.org/base/projects/bhyve/

Install binutils for building BHyVe enabled kernel.

pkg_add -r binutils

Build world, build kernel and install kernel.

cd /root/bhyve
make buildworld -DNO_WERROR
make buildkernel
make installkernel

Note: I noticed recent revision of bhyve tree cannot complete buildworld without -DNO_WERROR so I added it.

Set parameters on loader.conf and reboot.

echo hw.physmem="0x100000000" >> /boot/loader.conf
echo debug.witness.watch="0" >> /boot/loader.conf
reboot

hw.physmem="0x100000000" limits 4GB memory for host, give above to guests.
Ex: If you have 8GB on the machine, give 4GB to host, give another 4GB to guests.
If you have fewer memory on the machine, you MUST change this value. Otherwise the kernel may not boot.

Boot in single mode, install world.

(Input 'boot -s' in loader prompt, boot in single mode)

mount -u /
mount -a -t ufs
adjkerntz -i
mergemaster -m /root/bhyve -p
cd /root/bhyve
make installworld
mergemaster -m /root/bhyve
reboot

Migrate package manager to pkgng.

(This is optional sequence, and not related to BHyVe. But it looks like there's no other way to fetch binary package for 10-CURRENT)

echo "PACKAGESITE: http://pkgbeta.freebsd.org/freebsd-10-amd64/latest/" > /usr/local/etc/pkg.conf
pkg update
pkg2ng
pkg upgrade

Install wget, fetch a guest image, extract it.

pkg install wget
cd /root
wget http://mirrors.nycbug.org/pub/BHyVe/bhyve-guest-1gb-v2.tar.xz
tar xvpf bhyve-guest-1gb-v2.tar.xz

Congrats, install procedure is done. Let's boot the guest!

cd /root/bhyve-guest-1gb-v2
sh vmprep.sh
sh vmrun.sh