thelinuxvault blog

Install VirtualBox on Ubuntu 20.04 Focal Fossa Linux

VirtualBox is a powerful, open-source virtualization tool developed by Oracle that allows users to run multiple operating systems (OSes) simultaneously on a single physical machine. Whether you’re a developer testing software across platforms, a student exploring different Linux distributions, or a tech enthusiast experimenting with new OSes, VirtualBox provides a flexible and cost-effective solution.

Ubuntu 20.04 LTS (Focal Fossa) is a popular, stable Linux distribution widely used in both desktop and server environments. In this guide, we’ll walk through two reliable methods to install VirtualBox on Ubuntu 20.04: using Ubuntu’s default repositories (for stability) and Oracle’s official repository (for the latest features). We’ll also cover post-installation steps, verification, troubleshooting, and uninstallation.

2026-02

Table of Contents#

  1. Prerequisites
  2. Method 1: Install VirtualBox via Ubuntu Repository
  3. Method 2: Install VirtualBox via Oracle’s Official Repository
  4. Verifying the Installation
  5. Post-Installation Steps
  6. Uninstalling VirtualBox
  7. Troubleshooting Common Issues
  8. Conclusion
  9. References

Prerequisites#

Before installing VirtualBox, ensure your system meets these requirements:

  • Ubuntu 20.04 LTS: Confirm you’re running Focal Fossa with lsb_release -a (output should show Codename: focal).
  • sudo Access: You need administrative privileges to install packages.
  • Internet Connection: To download packages and repositories.
  • Virtualization Support: Your CPU must support hardware virtualization (Intel VT-x or AMD-V). To check, run:
    egrep -c '(vmx|svm)' /proc/cpuinfo
    If the output is 0, enable virtualization in your BIOS/UEFI settings (restart your PC and access BIOS/UEFI via keys like F2, Del, or F1).

Method 1: Install VirtualBox via Ubuntu Repository#

Ubuntu’s default apt repositories include a stable (but often older) version of VirtualBox. This method is ideal for users prioritizing stability over the latest features.

Step 1: Update System Packages#

First, update your package list and upgrade existing packages to avoid conflicts:

sudo apt update && sudo apt upgrade -y

Step 2: Install VirtualBox#

Install VirtualBox and its extension pack (adds support for USB 2.0/3.0, RDP, and disk encryption) with:

sudo apt install virtualbox virtualbox-ext-pack -y

During installation, you’ll be prompted to accept the Oracle license. Press Tab to select OK, then Enter, and select Yes to agree.

Method 2: Install VirtualBox via Oracle’s Official Repository#

For the latest VirtualBox version (recommended for new features and bug fixes), use Oracle’s official repository.

Step 1: Add Oracle’s GPG Key#

Oracle signs its packages with a GPG key to ensure authenticity. Import the key:

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

(If wget isn’t installed, run sudo apt install wget -y first.)

Step 2: Add Oracle’s Repository#

Add the VirtualBox repository for Ubuntu 20.04 (codename focal) to your system’s sources list:

echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian focal contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Step 3: Update and Install VirtualBox#

Update your package list to include the new repository, then install VirtualBox. As of 2024, the latest stable version is 6.1 (check VirtualBox’s download page for updates):

sudo apt update
sudo apt install virtualbox-6.1 -y

Step 4: Install the Extension Pack (Optional)#

The extension pack unlocks advanced features. Download the pack matching your VirtualBox version (replace 6.1.46 with your installed version from virtualbox --version):

wget https://download.virtualbox.org/virtualbox/6.1.46/Oracle_VM_VirtualBox_Extension_Pack-6.1.46.vbox-extpack

Install it with:

sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.46.vbox-extpack

Accept the license when prompted.

Verifying the Installation#

To confirm VirtualBox installed correctly:

Via Command Line#

Check the version:

virtualbox --version

Example output: 6.1.46_Ubuntur158378 (version numbers will vary).

Via GUI#

Launch VirtualBox from the Ubuntu applications menu (search for “VirtualBox”) or run:

virtualbox

A window like this should appear:
(Note: Add a screenshot here if publishing; describe as “VirtualBox Manager window with options to create/import VMs.”)

Post-Installation Steps#

Install VirtualBox Guest Additions#

Guest Additions are software packages installed on guest OSes (the OS running inside a VM) to improve performance (graphics, mouse integration) and add features (shared folders, clipboard sharing).

Steps to Install:#

  1. Start your VM and log in to the guest OS (e.g., Ubuntu, Windows).
  2. From the VirtualBox menu, go to Devices > Insert Guest Additions CD Image.
  3. If the guest OS auto-mounts the CD, open it and run the installer script:
    • For Linux guests: Open a terminal, navigate to the CD directory (e.g., /media/$USER/VBox_GAs_6.1.46), then run:
      sudo ./VBoxLinuxAdditions.run
    • For Windows guests: Double-click VBoxWindowsAdditions.exe and follow the wizard.
  4. Restart the VM when prompted.

Dependencies (Linux Guests):#

If the installer fails, install prerequisites first (run in the guest OS):

sudo apt install build-essential dkms linux-headers-$(uname -r) -y

Add User to vboxusers Group (for USB Access)#

To access USB devices in VMs, add your user to the vboxusers group:

sudo usermod -aG vboxusers $USER

Log out and back in for changes to take effect.

Uninstalling VirtualBox#

If you need to remove VirtualBox:

If Installed via Ubuntu Repository:#

sudo apt remove --purge virtualbox virtualbox-ext-pack -y
sudo apt autoremove -y  # Remove leftover dependencies

If Installed via Oracle Repository:#

sudo apt remove --purge virtualbox-6.1 -y
sudo apt autoremove -y

Remove Oracle Repository (Optional):#

sudo rm /etc/apt/sources.list.d/virtualbox.list
sudo apt update  # Refresh package list

Troubleshooting Common Issues#

1. “Kernel Driver Not Installed (rc=-1908)”#

This error occurs when the VirtualBox kernel module (vboxdrv) isn’t loaded. Fix it by:

sudo apt install --reinstall virtualbox-dkms  # Reinstall kernel modules
sudo modprobe vboxdrv  # Load the module

If the issue persists, check if Secure Boot is enabled (common on UEFI systems). Secure Boot blocks unsigned kernel modules. Disable it in your BIOS/UEFI settings, or sign the module (advanced users: follow Oracle’s guide).

2. “Failed to Open Session” (VM Won’t Start)#

  • Ensure virtualization is enabled in BIOS/UEFI.
  • Check for conflicting virtualization tools (e.g., VMware, KVM). Close them and try again.

3. USB Devices Not Detected#

  • Confirm your user is in the vboxusers group (see Post-Installation Steps).
  • Use the USB 3.0 (xHCI) Controller in VM settings (Settings > USB > Enable USB Controller > USB 3.0).

Conclusion#

You’ve successfully installed VirtualBox on Ubuntu 20.04! Whether you used Ubuntu’s stable repository or Oracle’s latest build, you can now create VMs to run Windows, macOS, other Linux distros, or even legacy OSes. Don’t forget to install Guest Additions for a smoother experience, and explore features like shared folders and snapshots to enhance your workflow.

References#