Ubuntu as a bhyve guest

My home router/server runs FreeBSD and recently got a CPU upgrade that allows for some more advanced services. I don’t have any machine running Linux at this point but I currently need one for some tasks. That’s why I thought setting up an Ubuntu virtual machine on the server would be neat. Luckily, FreeBSD 10 comes with the neat bhyve virtualization solution.


Load the kernel extension and create a tap interface for the subnet to use with the virtual machines:

# kldload vmm
# sysctl net.link.tap.up_on_open=1
# ifconfig tap0 create
# ifconfig tap0 inet

Add the following rules in the /etc/pf.conf to enable access to the tap network and NAT to the outside world:

tap_if = "tap0"
nat on $ext_if from $tap_if:network to any -> ($ext_if)
pass in on tap0 keep state

Reload PF rules:

# pfctl -f /etc/pf.conf

Create a new ZFS file system in device mode that will be used as the hard disk for the VM:

# zfs create -V256G -o volmode=dev pool/ubuntu_vm

The next step is to download an Ubuntu net installer image. This is required as Ubuntu will be installed without a graphical interface.

Install the linux boot loader grub and create a device.map for the grub bootloader:

# pkg install grub2-bhyve
# cat device.map 
(hd0) /dev/zvol/pool/ubuntu_vm
(cd0) ./mini.iso


Run grub and when prompted select the text based installation option:

grub-bhyve -r cd0 -m device.map -M 1024 ubuntu

Start the VM and follow the instructions. When prompted, manually configure the IP address to e.g.

# bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap0 -s 3:0,virtio-blk,/dev/zvol/pool/ubuntu_vm -s 4,ahci-cd,./mini.iso -l com1,stdio -c 2 -m 1024M ubuntu

When the installation is done and the VM terminates, it has to be manually destroyed:

# bhyvectl --destroy --vm=ubuntu

Starting the VM

Create a grub input file, run grub and run bhyve:

# cat grub.in 
set root=(hd0,msdos1)
linux /vmlinuz root=/dev/vda1
initrd /initrd.img

# grub-bhyve -r hd0 -m device.map -M 1024 ubuntu < grub.in > /dev/null
# bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc -s 2:0,virtio-net,tap0 -s 3:0,virtio-blk,/dev/zvol/pool/ubuntu_vm -l com1,stdio -c 2 -m 1024M ubuntu

Now would be a good time to install the sshd in ubuntu so it will also be accessible without having a console attached to the VM.

Making things persistent

To ensure that the changes to the system are persistent, the following steps are necessary:

# echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf

Add the following to /boot/loader.conf:


Add the following to /etc/rc.conf:




Rob & Nikki’s Wedding

About two weeks ago, I had the opportunity to be a wedding photographer for the first time. At Lindsey & Aaron’s wedding, I had just brought my camera for fun and they had hired a professional photographer. At Rob & Nikki’s wedding, they had asked me if I would take their pictures and be the photographer. After we had a discussion in which I told them that I wouldn’t want to be the guy that messes up their wedding pictures, I agreed to risk it.
Unfortunately, the weather wasn’t too good that day but nevertheless it was a great party and I had a lot of fun taking the pictures.

DSCF6434 DSCF6683 DSCF6705 DSCF6721 DSCF6814 DSCF6854 DSCF6977 DSCF7003 DSCF4550 DSCF4598 DSCF6477 DSCF6490 DSCF6509 DSCF6532 DSCF6594 DSCF6611 DSCF6670

Pre-Halloween Party

On Friday, Rob invited to a Halloween-themed Game Night at his place. Jessie and I went and had a lot of fun. I chose to wear a “European tourist” costume which was fairly easy to create. I already had Birkenstock sandals, a weird shirt, shorts and a camera. Only the white socks that go so nicely with the sandals had to be bought.

We played Carcassonne, Pandemic (which was horribly hard but fun) and Ca$h’n Guns (this time with Nerf Guns. DSCF7030

DSCF7031 DSCF7032 DSCF7033 DSCF7048 DSCF7025 DSCF7037 DSCF7040 DSCF7047

A photo posted by Jan-Niklas Meier (@dschanoeh) on