From Gentoo Wiki
Jump to: navigation, search
External resources

VirtualBox is cross-platform virtualization software that allows users to run guest operating systems inside a host operating system without having to reboot. Since 2010 VirtualBox software has been written and maintained by the Oracle Corporation.


Term Explaination
Host operating system The host computer. Most likely the physical hardware present in the room. For Gentoo users the host operating system would be Gentoo Linux
Guest operating system The operating system to be installed or currently installed inside the VirtualBox emulation environment. Possible alternative operating systems include Microsoft Windows, Solaris, BSD, Debian, Ubuntu, etc.
VirtualBox Guest Additions Drivers for the guest operating system. These drivers provide smoother operation with the Host operating system compared to the standard drivers installed by the Guest operating system.


There is a source based package (app-emulation/virtualbox) and a binary package (app-emulation/virtualbox-bin) available in the Portage tree. The binary version is available so 64bit no-multilib users can use VirtualBox, too. The binary package contains some extensions which are not available in the source package. To get identical functionality with the source package, emerge it with the extensions USE being enabled.

The qt4 USE controls installation of the graphical user interface (GUI) which is enabled by default.

USE configuration


USE flag (what is that?) Default Recommended Description
additions Yes Yes Install Guest System Tools ISO
alsa No Yes Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
doc No Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
extensions No Yes Install extension module packages
headless No Build without any graphic frontend
java No No Add support for Java
opengl Yes Add support for OpenGL (3D graphics)
pam No Yes Add support for PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily flip
pulseaudio No Add support for PulseAudio sound server
python No Add optional support/bindings for the Python language
qt4 Yes Yes Add support for the Qt GUI/Application Toolkit version 4.x
sdk Yes Enable building of SDK
vboxwebsrv No No Build and install the VirtualBox webservice
vnc No Enable VNC (remote desktop viewer) support
root #emerge --ask app-emulation/virtualbox


USE flag (what is that?) Default Recommended Description
additions Yes Yes Install Guest System Tools ISO
chm Yes Install kchmviewer binary to enable online help (in MS CHM format)
headless No Install without any graphic frontend
python No Add optional support/bindings for the Python language
rdesktop-vrdp No Install the rdesktop client integration
sdk No Enable building of SDK
vboxwebsrv No No Install the VirtualBox webservice
root #echo "app-emulation/virtualbox-bin PUEL" >> /etc/portage/package.license
root #emerge --ask app-emulation/virtualbox-bin

Windows Guests

Enable the additions USE when installing VirtualBox on the host system to get the ISO image that contains all necessary Windows guest drivers.

Linux Guests

In order to run Gentoo as a guest system, invoke the following command in the Gentoo guest operating system:

root #emerge --ask app-emulation/virtualbox-guest-additions

To enable the shared clipboard, display resizing, seamless mode and drag and drop make sure the user running the session belongs to the "vboxguest" group.

root #gpasswd -a <user> vboxguest

Changes will not take effect until the user signs out and then signs in again (re-logins).

To install other Linux distributions as guest operating systems please refer to the distribution's documentation on how to install the drivers needed by VirtualBox or consult the official VirtualBox documentation.


Users will not be able to run and use VirtualBox if they are not a member of the "vboxusers" group.

root #gpasswd -a <user> vboxusers

Changes will not take effect until the user re-logins.

Load the required driver module made available when app-emulation/virtualbox-modules was emerged:

root #modprobe vboxdrv

Optional modules:

root #modprobe vboxnetadp
root #modprobe vboxnetflt


Load the modules upon boot. When using OpenRC, edit /etc/conf.d/modules file. Add the following modules:

FILE /etc/conf.d/modules
modules="... vboxdrv vboxnetadp vboxnetflt ..."


When using systemd:

root #echo 'vboxdrv' >> /etc/modules-load.d/virtualbox.conf
root #echo 'vboxnetadp' >> /etc/modules-load.d/virtualbox.conf
root #echo 'vboxnetflt' >> /etc/modules-load.d/virtualbox.conf

Helpful packages

According to the ebuild's message after VirtualBox is installed sys-apps/usermode-utilities and net-misc/bridge-utils can be installed for advanced network configuration.


There are many options which can influence behavior and performance of the virtual machines. If you don't know what these options are doing, leave them to their defaults. Virtual machines may become unbootable if the wrong options are set.

Here is a list of options that are safe to use:

  • Host I/O cache can safely be enabled for all virtual storage controllers.
  • If the host system's CPU supports hardware virtualization, enable the 'VT-x/AMD-V' option. It can drastically increase the performance of the virtual machines.

Common Problems

virtualbox-modules fails to build

Some users have issues with the app-emulation/virtualbox-modules package failing to build. This can be caused by an improper kernel/profile configuration. Verify the chosen kernel and the selected profile match each other. For example, if a hardened profile is set, a hardened kernel should be used. If a default AMD64 profile is set, then the default gentoo-sources should be used. Run the eselect command to view the list of profile options:

root #eselect profile list
[1]   default/linux/amd64/13.0 *
[2]   default/linux/amd64/13.0/selinux
[3]   default/linux/amd64/13.0/desktop
[4]   default/linux/amd64/13.0/desktop/gnome
[5]   default/linux/amd64/13.0/desktop/gnome/systemd
[6]   default/linux/amd64/13.0/desktop/kde
[7]   default/linux/amd64/13.0/desktop/kde/systemd
[8]   default/linux/amd64/13.0/developer
[9]   default/linux/amd64/13.0/no-emul-linux-x86
[10]  default/linux/amd64/13.0/no-emul-linux-x86/desktop
[11]  default/linux/amd64/13.0/no-emul-linux-x86/desktop/gnome
[12]  default/linux/amd64/13.0/no-emul-linux-x86/desktop/gnome/systemd
[13]  default/linux/amd64/13.0/no-emul-linux-x86/desktop/kde
[14]  default/linux/amd64/13.0/no-emul-linux-x86/desktop/kde/systemd
[15]  default/linux/amd64/13.0/no-emul-linux-x86/developer
[16]  default/linux/amd64/13.0/no-emul-linux-x86/selinux
[17]  default/linux/amd64/13.0/no-multilib
[18]  default/linux/amd64/13.0/x32
[19]  hardened/linux/amd64
[20]  hardened/linux/amd64/selinux
[21]  hardened/linux/amd64/no-multilib
[22]  hardened/linux/amd64/no-multilib/selinux
[23]  hardened/linux/amd64/x32
[24]  hardened/linux/musl/amd64
[25]  default/linux/uclibc/amd64
[26]  hardened/linux/uclibc/amd64

Then use the eselect command again to display which kernel is selected:

root #eselect kernel list
[1]   linux-3.13.10-hardened
[2]   linux-3.16.3-hardened-r1
[3]   linux-3.17.2-hardened-r1
[4]   linux-3.18.4-hardened
[5]   linux-3.18.5-gentoo *

Looking at the outpout of these two commands, a user can determine if the system is setup properly (the profile matches the kernel) and should have no issues installing app-emulation/virtualbox-modules. Remember: Make sure the system profile and the selected kernel match!

Performance problems - Microsoft Windows Guest

  • Do not enable APIC for Microsoft Windows guests! VirtualBox also has a bad habit of enabling this option on its own will. The fix is to select the System Processor Driver (i.e. ACPI Uniprocessor PC) and manually upgrade (change) to the Advanced Configuration and Power Interface (ACPI) PC. Shutdown (not reboot), restart VirtualBox and ensure APIC is off, then boot the guest. As usual, always make a backup before playing with Windows.
    Not true for all Windows operating systems. Windows XP and Windows 7 play nice with APIC as long as they got installed with APIC being enabled.
  • Using a SATA controller, it is necessary to choose the right driver version from Intel's SATA drivers. Using a wrong version will cause performance problems along with blue screen errors! Refer to this post for a list of working SATA drivers.
  • Slow performance using SATA driver? Only use the SATA controller interface for the hard disk. Remove any CDROMs from the SATA controller and place them onto a IDE Controller.
    This can also be a problem of using the wrong SATA-driver version.
  • When installing the VirtualBox Guest Additions into your Windows operating system, do not select to enable Direct3D (experimental) option as this will cause resizing problems and other anomalies. Also, you need to install the Guest Additions from Safe Mode.
  • Do not use the ICH9 chipset with Windows. It is still considered experimental. Using it can cause temporary freezes of the whole VM when used with Windows 7. See this post for more informations.

Performance problems - Linux Guest

  • When running Gentoo as a guest system make sure you start the virtualbox-guest-additions init script during bootup.

Kernel driver not installed

VirtualBox-Error: Kernel driver not installed

This may occur after building a new kernel and causes an error message:

Kernel driver not installed (rc=-1908)
The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing
'/etc/init.d/vboxdrv setup'
as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.
Solution: Rebuild the VirtualBox kernel modules with
root #emerge -1 @module-rebuild

You may need to restart your computer to validate the change.

Nonexistent host networking interface, named 'vboxnet0'

root #VBoxManage hostonlyif create

Newly created interface will not be shown with ifconfig. You will have to assign some IP to it:

root #VBoxManage hostonlyif ipconfig vboxnet0 --ip

See also

External resources