How to Install Oracle VirtualBox on Ubuntu 22.04

Photo by Lukas on Unsplash

How to Install Oracle VirtualBox on Ubuntu 22.04

Oracle VirtualBox is a powerful, open-source, cross-platform virtualization software. It allows users to run multiple operating systems simultaneously on a single physical machine. This capability is extremely useful in various domains, including DevOps and Systems Engineering, where it serves several critical functions.

VirtualBox is categorized as Type2 hypervisor. It helps you to create guest operating systems (virtual machines) on a host operating system.

VirtualBox Installation:

  1. Download VirtualBox for Ubuntu 22.04.03 from https://www.virtualbox.org/wiki/Linux_Downloads

    💡
    The package architecture has to match the Linux kernel architecture, that is, if you are running a 64-bit kernel, install the appropriate AMD64 package (it does not matter if you have an Intel or an AMD CPU). Mixed installations (e.g. Debian/Lenny ships an AMD64 kernel with 32-bit packages) are not supported. To install VirtualBox anyway you need to setup a 64-bit chroot environment.
  2. Add the following line to your /etc/apt/sources.list. For Ubuntu 22.04 and older, replace '<mydist>' with 'jammy',

     deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian jammy contrib
    
  3. The Oracle public key for verifying the signatures can be downloaded here.

  4. Convert a downloaded binary GPG key file (usually with the .asc extension) into a keyring format. (If needed, move to the folder where the .asc key is located before executing the following command or provide the full path)

     sudo gpg --dearmor oracle_vbox_2016.asc
    

    The keyring format is more suitable for use with APT (Advanced Package Tool) and package managers.

  5. Move the formatted GPG key file into the following folder usr/share/keyrings.

     sudo mv oracle_vbox_2016.asc.gpg /usr/share/keyrings/oracle-virtualbox-2016.gpg
    

    The /usr/share/keyrings/ directory is a common location for storing keyring files that APT can use to verify the authenticity of packages from specific repositories.

  6. Before checking the fingerprint (a unique identifier for a GPG key that is used to verify its authenticity), import the GPG key from the oracle_vbox_2016.asc file into your GPG keyring using the command:

     gpg --import oracle_vbox_2016.asc
    
  7. Once the key is imported, view its fingerprint with the command:

     gpg --fingerprint key_identifier
    

    In this case, the key identifier is 2980AECF

  8. Finally, install VirtualBox with the command:

     sudo apt-get update
     sudo apt-get install virtualbox-6.1
    
  9. To verify that VirtualBox has been correctly installed on Ubuntu 22.04, check VirtualBox Version with the command:

     virtualbox --help
    

    OR

     VBoxManage --version
    
  10. For a more comprehensive check, you can create a new virtual machine and attempt to run it. If the VM starts correctly (even if it only displays a boot error message), VirtualBox is working as expected.

References:

  1. Download VirtualBox for Linux Hosts

  2. Oracle® VM VirtualBox® User Manual