23.3 FreeBSD as a Host OS

For a number of years, FreeBSD was not officially supported as a host OS by any of the available virtualization solutions. Some people were using older and mostly obsolete versions of VMware (like emulators/vmware3), which utilized the Linux® binary compatibility layer. Shortly after the release of FreeBSD 7.2, Sun's VirtualBox appeared in the Ports Collection as a native FreeBSD program.

VirtualBox is an actively developed, complete virtualization package, that is available for most operating systems including Windows®, Mac OS®, Linux and FreeBSD. It is equally capable at running Windows or UNIX® like guests. It is released as open source software, but with closed-source components available in a separate extension pack. These components include support for USB 2.0 devices, among others. More information may be found on the “Downloads” page of the VirtualBox wiki, at http://www.virtualbox.org/wiki/Downloads. Currently, these extensions are not available for FreeBSD.

23.3.1 Installing VirtualBox

VirtualBox is available as a FreeBSD port in emulators/virtualbox-ose. As VirtualBox is very actively developed, make sure your ports tree is up to date before installing. Install using these commands:

# cd /usr/ports/emulators/virtualbox-ose
# make install clean

One useful option in the configuration dialog is the GuestAdditions suite of programs. These provide a number of useful features in guest operating systems, like mouse pointer integration (allowing the mouse to be shared between host and guest without the need to press a special keyboard shortcut to switch) and faster video rendering, especially in Windows guests. The guest additions are available in the Devices menu, after the installation of the guest OS is finished.

A few configuration changes are needed before VirtualBox is started for the first time. The port installs a kernel module in /boot/modules which must be loaded into the running kernel:

# kldload vboxdrv

To ensure the module always gets loaded after a reboot, add the following line to /boot/loader.conf:


To use the kernel modules that allow bridged or host-only networking, add the following to /etc/rc.conf and reboot the computer:


The vboxusers group is created during installation of VirtualBox. All users that need access to VirtualBox will have to be added as members of this group. The pw command may be used to add new members:

# pw groupmod vboxusers -m yourusername

The default permissions for /dev/vboxnetctl are restrictive and need to be changed for bridged networking.

To test it temporarily:

# chown root:vboxusers /dev/vboxnetctl
# chmod 0660 /dev/vboxnetctl

To make the permissions change permanent, add these lines to /etc/devfs.conf:

own     vboxnetctl root:vboxusers
perm    vboxnetctl 0660

To launch VirtualBox, either select the Sun VirtualBox item from the graphic environment's menu, or type the following in a terminal:

% VirtualBox

For more information on configuring and using VirtualBox, please visit the official website at http://www.virtualbox.org. As the FreeBSD port is very recent, it is under heavy development. For the latest information and troubleshooting instructions, please visit the relevant page in the FreeBSD wiki, at http://wiki.FreeBSD.org/VirtualBox.

23.3.2 VirtualBox USB Support

Note: These steps require VirtualBox 4.0.0 or later.

In order to be able to read and write to USB devices, users need to be members of the operator group:

# pw groupmod operator -m jerry

Then, add the following to /etc/devfs.rules (create it if it does not exist yet):

add path 'usb/*' mode 0660 group operator

To load these new rules, add the following to /etc/rc.conf:


Then, restart devfs:

# /etc/rc.d/devfs restart

USB can now be enabled in the guest operating system. USB devices should be visible in the VirtualBox preferences.

23.3.3 VirtualBox Host DVD/CD Access

The atapicam kernel module needs to be loaded by adding the following line to /boot/loader.conf:


HAL needs to run for VirtualBox DVD/CD functions to work, so enable it in /etc/rc.conf and start it (if it is not already running):

# /usr/local/etc/rc.d/hald start

In order for users to be able to use VirtualBox DVD/CD functions, they need access to /dev/xpt0, /dev/cdN, and /dev/passN. Add the following lines to /etc/devfs.conf:

perm cd0 0600
perm xpt0 0660
perm pass0 0660