If you've decided to use VirtualBox in your environment (either for studying, testing distributions, or evaluating network services before implementation), we will set up our VirtualBox host in this activity.
Downloading and installing VirtualBox is actually fairly straightforward, but each platform has its unique quirks. In Windows, the initial installation is simply a matter of navigating to the following site and downloading the setup file and running through the installation wizard:
https://www.virtualbox.org/wiki/Downloads
After installation, all you would need to do is skip to the Downloading and installing the Extension Pack section of this chapter. Installing on Mac OS X is also straightforward.
For Linux, there are several methods to install VirtualBox. One way is to use your package manager, if your distribution already has it available in its repositories. Unfortunately, depending on the version of your distribution, the version of VirtualBox that may be included is very likely to be out of date. For example, Debian typically contains older packages in its repositories, but bleeding-edge distributions such as Arch are more likely to contain the latest and best.
Perhaps a better way of acquiring VirtualBox is to import the repositories that VirtualBox itself provides into your system. The following URL has a list of Debian repositories and even a method of adding a repository for RPM-based distributions (Fedora, Red Hat, and so on):
https://www.virtualbox.org/wiki/Linux_Downloads
For example, using the instructions on the page as a guide, we can run through the following procedure on a Debian-based system. However, Oracle may change their instructions and repository listing at any time; always consult the previous URL before installation to see if the procedure has changed.
To verify that we will add the correct version, we need to determine which repository to use. This differs based on which distribution you're running, so definitely consult the documentation on the VirtualBox site to ensure you're importing the correct repository.
For Debian 8 "Jessie", we would use the following:
deb http://download.virtualbox.org/virtualbox/debian jessie contrib
To add this repository to our Debian system, we would use the following command:
# echo "deb http://download.virtualbox.org/virtualbox/debian jessie contrib" > /etc/apt/sources.list.d/virtualbox.list
Then, we can add the public key for the repository with the following command:
# wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | apt-key add -
From now on, we can find Oracle's VirtualBox package in our repositories and install it. To do so, let's first update our package listing with the following command (as root):
# apt-get update
Then install VirtualBox with the following command:
# apt-get install dkms virtualbox-4.3
For distributions such as Fedora, Red Hat Enterprise Linux (RHEL) and openSUSE, Oracle provides similar instructions.
The public key can be downloaded via the following command:
# wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -
In order to add the repository to a Fedora system, execute the following command:
# wget -P /etc/yum/repos.d/ http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
After adding the repository, VirtualBox can be installed with the following command:
# yum install VirtualBox-4.3
In addition, instructions for OpenSUSE and RHEL are also available on the VirtualBox website. See the VirtualBox website for more details at https://www.virtualbox.org.
Oracle offers an Extension Pack, which enables USB support as well as support for Preboot Execution Environment (PXE) booting. You may or may not need these features. If you think you would benefit from being able to insert a flash drive on your host PC and accessing it from within your VM, it's probably a good idea to install the pack.
The installation procedure for the extension pack is mostly the same, regardless of whether your host computer is running Linux, Windows, or Mac OS X. However, there is one added step if your host is running Linux, which is to add your user account to the vboxusers
group.
cat /etc/group |grep vboxusers
vboxusers:x:1000:username
# groupadd vboxusers
# usermod -aG vboxusers yourusername
Now, you're ready to install the extension pack. Again, this procedure should be the same regardless of your underlying operating system. First, download the Extension Pack from the following URL and save it locally:
https://www.virtualbox.org/wiki/Downloads
After downloading, follow the next steps:
After this procedure, VirtualBox will be up and running on your machine.
In some distributions, the password prompt may not appear, causing the installation of the extension pack to fail. If that happens, run VirtualBox with root privileges using the following command:
sudo VirtualBox
Then, try installing the extension pack again. Once finished, close VirtualBox and then reopen it as a normal user before continuing.