Installing VirtualBox 2 on a Linux Host
This chapter of VirtualBox 2 Essentials covers the requirements for and steps to install the full, pre-built binrary edition of VirtualBox on a Linux host.
VirtualBox may be installed on Linux using either Linux distribution specific package archives, or manually using a distribution neutral shell script based installer. Each of these methods will be covered in this chapter.
VirtualBox Linux Host Requirements
Before embarking on an installation of VirtualBox on a Linux host, there a couple of pre-requisites. The following packages are required if access to the VirtualBox graphical interface is required. If only the headless VRDP server is required, the following packages are not mandated:
- Qt toolkit - Version 4.3.0 or newer of the Qt toolkit must be installed.
- SDL - Version 1.2.7 or newer of the libsdl graphics library must be installed.
Another, optional package is Dynamic Kernel Module Support (DKMS). As part of the installation process, VirtualBox installed two kernel modules (vboxdrv and vboxnetflt) onto the host system. These modules must match the running Linux kernel at all times for VirtualBox to function. This can be an issue when the host kernel is updated at any point in the future. Whilst not required to install and run VirtualBox the presence of the DKMS package will ease the transition to future kernel updates. When installed, DKMS ensures that the VirtualBox kernel modules are rebuilt automatically when the Linux kernel is updated. Without this package, the VirtualBox kernel module will need to be rebuilt manually each time a kernel update is applied to the host system.
The DKMS package is not supported on all Linux distributions, but may be installed on those that do as follows:
sudo apt-get install dkms
su yum install dkms
In addition to the above requirements, USB device support requires that the user account from which VirtualBox is running have read and write access to the usbfs USB filesystem. Also, if the virtual machines will be required to have access to host network adapters, the user must also have aread and write access to the /dev/net/tun device.
Downloading VirtualBox for Linux
The binary version of VirtualBox, pre-packaged for a wide variety of Linux distributions may be downloaded from the VirtualBox web site. Select the package which matches your Linux distribution (Fedora, Ubuntu, Red Hat, CentOS etc) and host architecture (i386 or AMD64) and download the archive to a suitable temporary location. If your Linux distribution is not listed download the appropriate archive for the All distributions option.
Installing VirtualBox on Fedora, CentOS and Red Hat Enterprise Linux
The packaged version of VirtualBox for Fedora, CentOS and Red Hat Enterprise Linux is supplied in the form of a Red Hat Package Management (rpm) file. When the link to download this archive is clicked, the browser will display a dialog providing the option to install the package using the Software Installer, or saving the file to disk. If the Software Installer is selected, a dialog similar to the following will appear once the download has completed.
To begin the installation, select the VirtualBox package and click the Apply button to initiate the installation process. If, during this process, the installer is unable to find pre-built kernel modules for the host operating system, it will attempt to build compatible modules from source code. If the installation is successful, a Software Installed Successfully dialog will appear and VirtualBox is ready to run.
If the installation fails, a log of the installation process, including any errors which were encountered, is stored in /var/log/vbox-install.log. Review any errors reported in the log file and take appropriate corrective action. If the installation failed attempting to built the VirtualBox kernel modules, the most likely explanation is that the Kernel development sources and headers necessary to build kernel modules are not installed on the system. To install these files, execute the following command:
su yum install kernel-devel
Once any problems relating to the build of the kernel modules have been rectified, the build can be restarted by executing the following command:
su - /etc/init.d/vboxdrv setup
An alternaive to installing VirtualBox using the graphical Software Installer tool is to install perform the installation from the command line. This can be achieved as follows:
# su - # rpm -ihv VirtualBox-2.1.4_42893_rhel5-1.i386.rpm Preparing... ########################################### [100%] 1:VirtualBox ########################################### [100%] Creating group 'vboxusers'. VM users must be member of that group! No precompiled module for this kernel found -- trying to build one. Messages emitted during module compilation will be logged to /var/log/vbox-install.log. Success!
As part of the installation process, a new group named vboxusers will be created on the host system. Any users which are intended to use VirtualBox must first be added to this group. This can be achieved by executing the following command:
# /usr/sbin/usermod -G vboxusers -a <username>
where <username> represents the name of the user to be added to the vboxusers group. Alternatively, users may be added to the group using the User Manager tool (accessed via the System->Administration->Users and Groups menu option.
Removing VirtualBox from a Fedora, CentOS and Red Hat Enterprise Linux Host
A VirtualBox instance installed from an RPM package may be uninstalled from the host by issuing the following command in a terminal window:
# rpm -e VirtualBox
Installing VirtualBox on Ubuntu
When the download link for the Ubuntu VirtualBox installation archive is clicked, the browser will provide the option to open the archive in the Package Installer. If this option is selected, the installer will appear as illustrated in the following figure:
To begin the installation process, click on the Install Package button and enter your password when prompted to do so. After a short period of time, the DebConf Configuration process for VirtualBox will begin. The first screen warns that any users of VirtualBox will need to be added to the vboxusers group. The next screen asks whether the kernel modules should be built and installed on the host system. Accept the default option (compile kernel module) and click the Forward button to continue the installation. Once the installation has completed successfully, the installer will display an Installation Finished. If any errors occurred during the installation, details can be found in the /var/log/vbox-install.log file.
An alternative to installing VirtualBox using the Package Installer is to perform the installation from the command line. Once the installation archive has been save to disk, the installation may be invoked as follows:
sudo dpkg -i virtualbox-2.1_2.1.4-42893_Ubuntu_intrepid_i386.deb
Before launching VirtualBox, any user which require access must be added to the vboxusers group. This can be performed by using the graphical Users and Groups tool (accessed via the System->Administration->Users and Groups menu option). Once invoked, click Unlock, enter your password and then click on the Manage Groups button. In the Manage Groups screen, select vboxusers from the list of groups, click on Properties and in the resulting dialog select the users which are to be added to the group.
Alternatively, users may be added to a group from the command line by issuing the following command:
sudo usermod -a -G vboxusers <username>
where <username> represents the name of the user to be added to the vboxusers group.
Uninstalling VirtualBox from an Ubuntu Host
An instance of VirtualBox installed from a .deb package file may be uninstalled at any time by issuing the following command in a terminal window (Applications->Accessories->Terminal):
$ sudo dpkg -r virtualbox-2.1 (Reading database ... 210619 files and directories currently installed.) Removing virtualbox-2.1 ... * Stopping VirtualBox kernel module * done.