VirtualBox Guest Additions on FreeBSD 10 (Repost)

Posted by mwguy on Sun 18 October 2015

FreeBSD 10 Setup Virtualbox Guest Additions : Reprint

Note for Visitors

I've had to recover my website and this was one of my most popular posts. However between when I originally published this and now the FreeBSD handbook has come out with a page explicitly describing how to accomplish this task (Linked here for your convenience). I would highly suggest following that guide and only coming here for some background context.

Introduction

For this guid I’m going to install VirtualBox Guest additions for a VBOX guest running FreeBSD 10. I’ve already installed sudo on this box.

Handbook section for reference

Install Guest Additions Packages

Install the Guest Additions using pkgng. It will install a number of dependencies including most of Xorg, DBUS and HALD.

sudo pkg install virtualbox-ose-additions

Recently it has come to my attention that virtualbox-ose-additions is not always available as a binary package. So here is an alternate way to install using ports. (Tip from the handbook)

First enable PKGNG to talk with your ports tree by editing /etc/make.conf

WITH_PKGNG= yes

Grab the latest ports tree and update it. If you have used portsnap before you can replace the extract command.

sudo portsnap fetch
sudo portsnap extract #Only needed if this is your first time
sudo portsnap update  #Only needed if you've already extracted once

Then Configure the Port and it’s dependencies:

cd /usr/ports/emulators/virtualbox-ose-additions
sudo make config-recursive

Then make the port. You may run into some issue compiling the port if there is a missing dependency or if a dependency or the port itself is not compiling at the moment. The freebsd forum are a good place to go for help. In addition you can comment below and I will help as time allows. Note I wasn’t able to compile the port with 512MB of RAM for my VM. I would suggest bumping it up to 1024MB if only for the build portion of this guide.

sudo make
# Get Coffee
sudo make install

Note I had troubles getting devel/glib20 to install. So I installed the package.

sudo pkg install devel/glib20

Then proceed to the configuration part of this install guide.

Configuration

Configure the service to start at boot. Add these lines to /etc/rc.conf.

vboxguest_enable="YES"
vboxservice_enable="YES"
## Only use this line if you have NTP enabled in the VM.
vboxservice_flags="--disable-timesync"

The last line should be left of if you’re not using ntp.

Then configure HALD/DBUS to start automatically by adding this section into /etc/rc.conf:

dbus_enable="YES"
hald_enable="YES"

Then reboot to pick up the changes.

% sudo reboot

Check that modules loaded successfully by running these commands as root (or with sudo):

% service dbus status
dbus is running as pid ###.
% service hald status
hald is running as pid ###.

Numbers will vary by system.

Check that the VBOX additions loaded successfully.

% kldstat | grep -i vbox

Should return a hex string and ``vboxguest.ko & vboxvideo.ko``

Potential Security Concern

From the pkg-message:

You also have to add all X11 users that want to use any of the additional
features (clipboard sharing, window scaling) to the wheel group.

% pw groupmod wheel -m jerry

If you followed my sudo guide you’ve given everyone in the wheel group access to run all commands. This is fine if it’s just you. But you may want to create a new sudo group to handle your admins and then add anyone who needs to run X from your VM.