How to install Oracle VirtualBox on Linux

If a Windows user wants to test Linux distribution, or a Linux user wants to try other Linux distributions, I would advise you guys to use Oracle Virtualbox to test this because virtualization software won’t harm anything on your system.

Not only VirtualBox but also you can use other alternatives such as QEMU, VMware Workstation Player, etc. I prefer VirtualBox because I was using more than 6 years.

What is VirtualBox?

VirtualBox (formerly known as Sun VirtualBox, Sun xVM VirtualBox and Innotek VirtualBox) is an open source cross-platform virtualization software for x86 architecture and run on Linux, Windows & Mac.

It was initially built & developed by Innotek GmbH and it was acquired by Sun Microsystems in 2008, later it was acquired by Oracle in 2010 and currently being developed by Oracle Corporation.

It allows for other operating systems (known as Guests) to be installed and run within an existing operating system (known as the Host).

All of the features are available in the Free version as well for personal use and not for commercial use.

The separate “VirtualBox Oracle VM VirtualBox extension pack” providing support for USB 2.0 and 3.0 devices, VirtualBox Remote Desktop Protocol (VRDP), disk encryption, NVMe and Preboot Execution Environment (PXE).

Oracle defines personal use as the installation of the software on a single host computer for non-commercial purposes.

VirtualBox is an amazing software that has a lot of features compared with other virtualization software such as QEMU, VMware,etc.., and still the development team hardly working on VirtualBox to improve stability.

Navigate to the following article to install Oracle Virtualbox on Arch Linux/Manjaro systems.

If you had installed virtualbox on headless server and would you like to install front end tool for easy management? I can suggest you to use phpVirtualBox or RemoteBox.

How to install VirtualBox on Linux

The VirtualBox package is available on most Linux distributions, so you can easily install it from the distribution official repository. But, if you are looking for the latest version of VirtualBox, add the VirtualBox official repositories and follow the below steps to install it.

For Ubuntu/Debian:

Import VirtualBox public key

$ 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 -

Add VirtualBox repository

$ sudo sh -c "echo 'deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian '$(lsb_release -cs)' contrib non-free' > /etc/apt/sources.list.d/virtualbox.list"

Update repository index

$ sudo apt update

Finally install VirtualBox

$ sudo apt install VirtualBox-6.1

Launch VirtulBox.

$ virtualbox

For CentOS/RHEL 8:

Install dependency packages

$ sudo dnf install kernel-devel kernel-devel-$(uname -r) kernel-headers kernel-headers-$(uname -r) dkms elfutils-libelf-devel

Import VirtualBox public key

$ sudo wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -

Add VirtualBox repository

$ sudo dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo

Finally install VirtualBox

$ sudo dnf install VirtualBox-6.1

Add a user to the vbox Group

$ sudo usermod -a -G vboxusers $USER

For CentOS/RHEL 6/7:

$ sudo yum install kernel-devel kernel-devel-$(uname -r) kernel-headers kernel-headers-$(uname -r) dkms
$ sudo wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -
$ sudo yum-config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/el/virtualbox.repo
$ sudo yum install VirtualBox-6.1
$ sudo usermod -a -G vboxusers $USER

For Fedora:

$ sudo dnf install kernel-devel kernel-devel-$(uname -r) kernel-headers kernel-headers-$(uname -r) dkms elfutils-libelf-devel
$ sudo wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -
$ sudo dnf config-manager --add-repo=https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
$ sudo dnf install VirtualBox-6.1
$ sudo usermod -a -G vboxusers $USER

For openSUSE:

$ sudo zypper install kernel-devel kernel-devel-$(uname -r) kernel-headers kernel-headers-$(uname -r) dkms
$ sudo wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -
$ sudo zypper addrepo https://download.virtualbox.org/virtualbox/rpm/opensuse/virtualbox.repo
$ sudo zypper install VirtualBox-6.1
$ sudo usermod -a -G vboxusers $USER

Rebuild VirtualBox kernel module

After installing VirtualBox on rpm based systems such as RHEL, CentOS, Fedora and openSUSE, it’s necessary to rebuild kernel modules to make it work properly. Use the below commands to rebuild VirtualBox kernel module.

[For SysVinit Systems]
$ sudo /etc/init.d/vboxdrv setup

[For systemd Systems]
$ sudo /usr/lib/virtualbox/vboxdrv.sh setup

Run the following command to launch VirtulBox.

# virtualbox

How to install VirtualBox extension

VirtualBox Extension pack ads additional future to virtualbox such as Support for USB 2.0 and USB 3.0 devices, VirtualBox RDP and PXE boot & Disk image encryption with AES algorithm.

$ sudo wget https://download.virtualbox.org/virtualbox/6.1.16/Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack

For uninstalling virtualbox extension pack, just follow the below procedure.

[Check virtualbox Extension pack version]
$ vboxmanage list extpacks

[Remove virtualbox Extension pack version]
$ sudo VBoxManage extpack uninstall "Oracle VM VirtualBox Extension Pack"

How to launch VirtualBox

You can launch VirtualBox from application menu.

Create New VM’s and refresh/learn new things…Have a great DAY..)

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian →

22 Comments on “How to install Oracle VirtualBox on Linux”

  1. @disqus_NuuLtlImfE:disqus @jakzov:disqus,
    I have clearly mentioned on point number 2, 2a & 2b. We need to uninstall old series before proceeding new series installation. We can directly do the upgrade without uninstall when we have same series, like (5.1 to 5.1.x). Hope this will clear your queries.

    1. what we say is that it’s wrong information. It it NOT necessary to uninstall, say 5.0.x (tested myself)
      Hence, we (you) should reinvestigate that requirement for older version as well, 5.1.2 might very well have come to properly handle the upgrade process for those. The only source I have for my say is my own experiment (upgrade from 5.0.x to 5.1.2 without uninstall)
      as well as some confirmed advice on irc > freenode > #virtualbox channel.

      what are your sources ? (sources should always be mentioned)

  2. So, shall we uninstall or not prior to upgrade ? (most ppl hear) is not relevent for readers
    Also, you don’t mention what are those step for in the title… (could be useful.. who knows)

  3. When I try to Install Virtualbox-5.0
    [[email protected] ~]$ sudo dnf install virtualbox-5.0
    Last metadata expiration check: 0:00:30 ago on Wed May 4 15:39:40 2016.
    No package virtualbox-5.0 available.
    Error: Unable to find a match.
    All the above other commands worked fine… Please suggest solution…

    1. Prasad,
      Can you please cross check whether Virtaulbox fedora repo added @ /etc/yum.repos.d

      # dnf config-manager –add-repo=http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo

      If so, run
      # dnf makecache

      then try it.

  4. After to update to the latest version of VirtualBox (5.0.16). When I try to insert some USB device, I don’t see any USB device in menu Devices->USB

    1. It’s OK now…I was checking into /etc/groups and I noticed that the group vboxusers was missing. I created again e relogin my user..now It’s OK.

  5. Help! After installing the upgrade, I get this error when opening my image:
    Failed to open a session for the virtual machine Win7.

    VD: error VERR_NOT_SUPPORTED opening image file ‘/Users/nan/VirtualBox VMs/Windows 7.vmdk’ (VERR_NOT_SUPPORTED).

    Failed to load unit ‘lsilogicscsi’ (VERR_SSM_LOADED_TOO_MUCH).

    Result Code: NS_ERROR_FAILURE (0x80004005)
    Component: ConsoleWrap
    Interface: IConsole {872da645-4a9b-1727-bee2-5585105b9eed}

Leave a Reply