Page 1 of 1

How to Install VirtualBox on Ubuntu/Debian-based Linux distributions

Posted: Tue Mar 20, 2018 3:01 pm
by Eli
VirtualBox is a free and open source virtualization software that can be used for enterprise as well as home edition. it allows you to create and run guest operating systems (virtual machines) on top of the existing operating system (host). VirtualBox can be installed to run on host operating systems such as Linux-based distributions, Windows, Solaris, OS X, and OpenSolaris.

See our previous post on VirtualBox and Genymotion: install-whatsapp-on-ubuntu-or-other-lin ... utions-580

VirtualBox is released under GPL v2, and Oracle VM VirtualBox extension pack is released under PUEL (Personal Use and Evaluation License). Everytime you install VirtualBox make sure to install the extension pack as well. The pack enables Virtual Remote Desktop Protocol (VRDP) and a lot other enhancements. Always install the extension pack with the same version as your installed version of VirtualBox.

The current version and some older versions of VirtualBox supports 32bit and 64bit host and guest operating systems (to be able to run 64bit guests, make sure your processor supports hardware virtualization and the host operating system is 64bit as well).

You can install VirtualBox by either using precompiled binaries (.deb packages) or from source. This guide focuses on installing the latest version of VirtualBox from the official Oracle repository on Ubuntu 16.04 and Debian 8.

You can install VirtualBox using the .deb binaries, by downloading an appropriate package from https://www.virtualbox.org/wiki/Linux_Downloads for Linux-based distributions or from https://www.virtualbox.org/wiki/Downloads for other operating systems, compile it and follow instructions.

As for the time of this post, the latest release of VirtualBox is 5.2.8.

Installing VirtualBox on Ubuntu/Debian-based Linux distributions

If you have an old versions of VirtualBox installed from Ubuntu or Debian repository, open the Terminal (Ctrl+Alt+T) and remove it with:

Code: Select all

sudo apt-get remove virtualbox
Next, open /etc/apt/sources.list file:

Code: Select all

sudo nano /etc/apt/sources.list


Ctrl + O to save changes, Ctrl + X to exit.

Or

Code: Select all

gksudo gedit /etc/apt/sources.list
and append the following line at the end of your /etc/apt/sources.list file:

Code: Select all

deb https://download.virtualbox.org/virtualbox/debian <mydist> contrib
Depending on your distribution, replace '<mydist>' with 'artful', 'zesty', 'yakkety', 'xenial', 'trusty', 'stretch', 'jessie', or 'wheezy' (older versions of VirtualBox supported different distributions), for example:

Add the following line at the end of the sources file if you are using Ubuntu 16.04:

Code: Select all

deb http://download.virtualbox.org/virtualbox/debian xenial contrib
Add the following line at the end of the sources file if you are using Debian 8 Jessie:

Code: Select all

deb http://download.virtualbox.org/virtualbox/debian jessie contrib
Save and close the file. Now fetch the Oracle GPG public key for apt-secure and import it to your Ubuntu 16.04/Debian 8 system (check GPG public key for older distributions) so packages downloaded from Oracle repository can be verified as trusted. You can add these keys for Ubuntu Xenial (and later) and Debian 8 Jessie, respectively, with the commands:

Code: Select all

sudo apt-key add oracle_vbox_2016.asc
sudo apt-key add oracle_vbox.asc
or by combined downloading and registering:

Code: Select all

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -

Verify that the key fingerprint for oracle_vbox_2016.asc is

Code: Select all

B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
and the key fingerprint for oracle_vbox.asc is

Code: Select all

7B0F AB3A 13B9 0743 5925  D9C9 5442 2A4B 98AB 5139
Oracle Corporation (VirtualBox archive signing key) <info@virtualbox.org>
Update the local package index:

Code: Select all

sudo apt-get update
and next install VirtualBox 5.2.x:

Code: Select all

sudo apt-get install virtualbox-5.2
Install dkms packages - this ensure that the VirtualBox host modules are correctly updated if the kernel version changes during the next upgrade.

Code: Select all

sudo apt-get install dkms
For Xenial 16.04 and higher, you can also get the extension pack from the Canonical repositories. Go to the terminal and execute:

Code: Select all

sudo apt install virtualbox-ext-pack
Therefore, for Xenial 16.04 and later distributions, you can get VirtualBox and the extension pack by typing the following:

Code: Select all

sudo apt install virtualbox virtualbox-ext-pack
and following the instructions on your screen.

Finally, launch the VirtualBox by starting

Code: Select all

VirtualBox (Dash >> Search >> Oracle VM VirtualBox)
OR by typing in the Unity Dash:

Code: Select all

virtualbox

Re: How to Install VirtualBox on Ubuntu/Debian-based Linux distributions

Posted: Sun Nov 18, 2018 10:24 pm
by Eli
Install VirtualBox on Ubuntu 18.04 LTS

Firstly, add the repository key. This adds a layer of security, since the key allows Ubuntu to authenticate and validate that all packages downloaded from the repository are trusted and signed with the appropriate repository key:

  1. $wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
  2. $wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -


Add VirtualBox repository to Ubuntu to immediately get the latest releases as soon as they become available:

  1. sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list'


Update Ubuntu repository:

$sudo apt-get update

Remove old version of VirtualBox if installed (replace virtualbox-5.1 appropriately depending on the version you're running):

$sudo apt remove virtualbox virtualbox-5.1

Run the commands below to install some VirtualBox dependencies:

  1. $sudo apt update
  2. $sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms


Lastly, install VirtualBox:

  1. $sudo apt update
  2. $sudo apt-get install virtualbox-5.2


We can now install and run guest operating systems on VirtualBox.