2.3. Installing on Linux Hosts

2.3.1. Prerequisites

For the various versions of Linux that are supported as host operating systems, see Section 1.4, “Supported Host Operating Systems”.

You may need to install the following packages on your Linux system before starting the installation. Some systems will do this for you automatically when you install Oracle VM VirtualBox.

  • Qt 5.3.2 or later. Qt 5.6.2 or later is recommended.

  • SDL 1.2.7 or later. This graphics library is typically called libsdl or similar.

Note

These packages are only required if you want to run the Oracle VM VirtualBox graphical user interfaces. In particular, VirtualBox, the graphical VirtualBox Manager, requires both Qt and SDL. If you only want to run VBoxHeadless, neither Qt nor SDL are required.

2.3.2. The Oracle VM VirtualBox Kernel Modules

In order to run other operating systems in virtual machines alongside your main operating system, Oracle VM VirtualBox needs to integrate very tightly with your system. To do this it installs a driver module called vboxdrv into the system kernel. The kernel is the part of the operating system which controls your processor and physical hardware. Without this kernel module, you can still use the VirtualBox Manager to configure virtual machines, but they will not start.

Network drivers called vboxnetflt and vboxnetadp are also installed. They enable virtual machines to make more use of your computer's network capabilities and are needed for any virtual machine networking beyond the basic NAT mode.

Since distributing driver modules separately from the kernel is not something which Linux supports well, the Oracle VM VirtualBox install process creates the modules on the system where they will be used. This means that you may need to install some software packages from the distribution which are needed for the build process. Required packages may include the following:

  • GNU compiler (GCC)

  • GNU Make (make)

  • Kernel header files

Also ensure that all system updates have been installed and that your system is running the most up-to-date kernel for the distribution.

Note

The running kernel and the kernel header files must be updated to matching versions.

The following list includes some details of the required files for some common distributions. Start by finding the version name of your kernel, using the command uname -r in a terminal. The list assumes that you have not changed too much from the original installation, in particular that you have not installed a different kernel type.

  • With Debian and Ubuntu-based distributions, you must install the correct version of the linux-headers, usually whichever of linux-headers-generic, linux-headers-amd64, linux-headers-i686 or linux-headers-i686-pae best matches the kernel version name. Also, the linux-kbuild package if it exists. Basic Ubuntu releases should have the correct packages installed by default.

  • On Fedora, Red Hat, Oracle Linux and many other RPM-based systems, the kernel version sometimes has a code of letters or a word close to the end of the version name. For example "uek" for the Oracle Unbreakable Enterprise Kernel or "default" or "desktop" for the standard kernels. In this case, the package name is kernel-uek-devel or equivalent. If there is no such code, it is usually kernel-devel.

  • On some SUSE and openSUSE Linux versions, you may need to install the kernel-source and kernel-syms packages.

If you suspect that something has gone wrong with module installation, check that your system is set up as described above and try running the following command, as root:

rcvboxdrv setup

2.3.2.1. Kernel Modules and UEFI Secure Boot

If you are running on a system using UEFI (Unified Extensible Firmware Interface) Secure Boot, you may need to sign the following kernel modules before you can load them:

  • vboxdrv

  • vboxnetadp

  • vboxnetflt

  • vboxpci

See your system documentation for details of the kernel module signing process.

2.3.3. Performing the Installation

Oracle VM VirtualBox is available in a number of package formats native to various common Linux distributions. See Section 1.4, “Supported Host Operating Systems”. In addition, there is an alternative generic installer (.run) which you can use on supported Linux distributions.

2.3.3.1. Installing Oracle VM VirtualBox from a Debian or Ubuntu Package

Download the appropriate package for your distribution. The following example assumes that you are installing to a 64-bit Ubuntu Xenial system. Use dpkg to install the Debian package,as follows:

sudo dpkg -i virtualbox-6.0_version-number_Ubuntu_xenial_amd64.deb

The installer will also try to build kernel modules suitable for the current running kernel. If the build process is not successful you will be shown a warning and the package will be left unconfigured. Look at /var/log/vbox-install.log to find out why the compilation failed. You may have to install the appropriate Linux kernel headers, see Section 2.3.2, “The Oracle VM VirtualBox Kernel Modules”. After correcting any problems, run the following command:

sudo rcvboxdrv setup

This will start a second attempt to build the module.

If a suitable kernel module was found in the package or the module was successfully built, the installation script will attempt to load that module. If this fails, please see Linux Kernel Module Refuses to Load for further information.

Once Oracle VM VirtualBox has been successfully installed and configured, you can start it by clicking VirtualBox in your Start menu or from the command line. See Section 2.3.5, “Starting Oracle VM VirtualBox on Linux”.

2.3.3.2. Using the Alternative Generic Installer (VirtualBox.run)

The alternative generic installer performs the following steps:

  • Unpacks the application files to the target directory /opt/VirtualBox/, which cannot be changed.

  • Builds and installs the Oracle VM VirtualBox kernel modules: vboxdrv, vboxnetflt, and vboxnetadp.

  • Creates /sbin/rcvboxdrv, an init script to start the Oracle VM VirtualBox kernel module.

  • Creates a new system group called vboxusers.

  • Creates symbolic links in /usr/bin to a shell script /opt/VirtualBox/VBox which does some sanity checks and dispatches to the actual executables: VirtualBox, VBoxVRDP, VBoxHeadless and VBoxManage.

  • Creates /etc/udev/rules.d/60-vboxdrv.rules, a description file for udev, if that is present, which makes the USB devices accessible to all users in the vboxusers group.

  • Writes the installation directory to /etc/vbox/vbox.cfg.

The installer must be executed as root with either install or uninstall as the first parameter. For example:

sudo ./VirtualBox.run install

Or if you do not have the sudo command available, run the following as root instead:

./VirtualBox.run install

Add every user who needs to access USB devices from a VirtualBox guests to the group vboxusers. Either use the OS user management tools or run the following command as root:

sudo usermod -a -G vboxusers username
Note

The usermod command of some older Linux distributions does not support the -a option, which adds the user to the given group without affecting membership of other groups. In this case, find out the current group memberships with the groups command and add all these groups in a comma-separated list to the command line after the -G option. For example: usermod -G group1,group2,vboxusers username.

2.3.3.3. Performing a Manual Installation

If you cannot use the shell script installer described in Section 2.3.3.2, “Using the Alternative Generic Installer (VirtualBox.run)”, you can perform a manual installation. Run the installer as follows:

./VirtualBox.run --keep --noexec

This will unpack all the files needed for installation in the directory install under the current directory. The Oracle VM VirtualBox application files are contained in VirtualBox.tar.bz2 which you can unpack to any directory on your system. For example:

sudo mkdir /opt/VirtualBox
sudo tar jxf ./install/VirtualBox.tar.bz2 -C /opt/VirtualBox

To run the same example as root, use the following commands:

mkdir /opt/VirtualBox
tar jxf ./install/VirtualBox.tar.bz2 -C /opt/VirtualBox

The sources for Oracle VM VirtualBox's kernel module are provided in the src directory. To build the module, change to the directory and use the following command:

make

If everything builds correctly, run the following command to install the module to the appropriate module directory:

sudo make install

In case you do not have sudo, switch the user account to root and run the following command:

make install

The Oracle VM VirtualBox kernel module needs a device node to operate. The above make command will tell you how to create the device node, depending on your Linux system. The procedure is slightly different for a classical Linux setup with a /dev directory, a system with the now deprecated devfs and a modern Linux system with udev.

On certain Linux distributions, you might experience difficulties building the module. You will have to analyze the error messages from the build system to diagnose the cause of the problems. In general, make sure that the correct Linux kernel sources are used for the build process.

Note that the /dev/vboxdrv kernel module device node must be owned by root:root and must be read/writable only for the user.

Next, you install the system initialization script for the kernel module and activate the initialization script using the right method for your distribution, as follows:

cp /opt/VirtualBox/vboxdrv.sh /sbin/rcvboxdrv

This example assumes you installed Oracle VM VirtualBox to the /opt/VirtualBox directory.

Create a configuration file for Oracle VM VirtualBox, as follows:

mkdir /etc/vbox
echo INSTALL_DIR=/opt/VirtualBox > /etc/vbox/vbox.cfg

Create the following symbolic links:

ln -sf /opt/VirtualBox/VBox.sh /usr/bin/VirtualBox
ln -sf /opt/VirtualBox/VBox.sh /usr/bin/VBoxManage
ln -sf /opt/VirtualBox/VBox.sh /usr/bin/VBoxHeadless

2.3.3.4. Updating and Uninstalling Oracle VM VirtualBox

Before updating or uninstalling Oracle VM VirtualBox, you must terminate any virtual machines which are currently running and exit the Oracle VM VirtualBox or VBoxSVC applications. To update Oracle VM VirtualBox, simply run the installer of the updated version. To uninstall Oracle VM VirtualBox, run the installer as follows:

sudo ./VirtualBox.run uninstall

As root, you can use the following command:

./VirtualBox.run uninstall

You can uninstall the .run package as follows:

/opt/VirtualBox/uninstall.sh

To manually uninstall Oracle VM VirtualBox, perform the manual installation steps in reverse order.

2.3.3.5. Automatic Installation of Debian Packages

The Debian packages will request some user feedback when installed for the first time. The debconf system is used to perform this task. To prevent any user interaction during installation, default values can be defined. A file vboxconf can contain the following debconf settings:

virtualbox virtualbox/module-compilation-allowed boolean true
virtualbox virtualbox/delete-old-modules boolean true

The first line enables compilation of the vboxdrv kernel module if no module was found for the current kernel. The second line enables the package to delete any old vboxdrv kernel modules compiled by previous installations.

These default settings can be applied prior to the installation of the Oracle VM VirtualBox Debian package, as follows:

debconf-set-selections vboxconf

In addition there are some common configuration options that can be set prior to the installation. See Section 2.3.3.7, “Automatic Installation Options”.

2.3.3.6. Automatic Installation of RPM Packages

The RPM format does not provide a configuration system comparable to the debconf system. See Section 2.3.3.7, “Automatic Installation Options” for how to set some common installation options provided by Oracle VM VirtualBox.

2.3.3.7. Automatic Installation Options

To configure the installation process for .deb and .rpm packages, you can create a response file named /etc/default/virtualbox. The automatic generation of the udev rule can be prevented with the following setting:

INSTALL_NO_UDEV=1

The creation of the group vboxusers can be prevented as follows:

INSTALL_NO_GROUP=1

If the following line is specified, the package installer will not try to build the vboxdrv kernel module if no module fitting the current kernel was found.

INSTALL_NO_VBOXDRV=1

2.3.4. The vboxusers Group

The Linux installers create the system user group vboxusers during installation. Any system user who is going to use USB devices from Oracle VM VirtualBox guests must be a member of that group. A user can be made a member of the group vboxusers either by using the desktop user and group tools, or with the following command:

sudo usermod -a -G vboxusers username

2.3.5. Starting Oracle VM VirtualBox on Linux

The easiest way to start an Oracle VM VirtualBox program is by running the program of your choice (VirtualBox, VBoxManage, or VBoxHeadless) from a terminal. These are symbolic links to VBox.sh that start the required program for you.

The following detailed instructions should only be of interest if you wish to execute Oracle VM VirtualBox without installing it first. You should start by compiling the vboxdrv kernel module and inserting it into the Linux kernel. Oracle VM VirtualBox consists of a service daemon, VBoxSVC, and several application programs. The daemon is automatically started if necessary. All Oracle VM VirtualBox applications will communicate with the daemon through UNIX local domain sockets. There can be multiple daemon instances under different user accounts and applications can only communicate with the daemon running under the user account as the application. The local domain socket resides in a subdirectory of your system's directory for temporary files called .vbox-<username>-ipc. In case of communication problems or server startup problems, you may try to remove this directory.

All Oracle VM VirtualBox applications (VirtualBox, VBoxManage, and VBoxHeadless) require the Oracle VM VirtualBox directory to be in the library path, as follows:

LD_LIBRARY_PATH=. ./VBoxManage showvminfo "Windows XP"