How to Install VirtualBox 6.1 on Ubuntu 22.04 LTS in Minutes
Installing VirtualBox 6.1 on Ubuntu 22.04 LTS is a one‑liner if you know the right repo and a couple of quirks that can trip up even seasoned users. This guide walks through the exact steps, explains why each one matters, and covers a common hiccup you’ll hit after an OS upgrade.
1. Add Oracle’s GPG Key
VirtualBox packages are signed by Oracle; without the key apt will refuse to install them.
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo tee /etc/apt/trusted.gpg.d/virtualbox.asc > /dev/null
Why it matters: The key protects you from tampered packages and keeps the package manager happy.
2. Add the VirtualBox Repository
Ubuntu’s default repos only ship with an older VirtualBox version (5.x). Oracle hosts newer releases on its own server.
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian jammy contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
Why it matters: Pulling from the official repo guarantees you get the latest 6.1 build and its bug fixes.
3. Update Package Lists
sudo apt update
If the update fails, double‑check that the URL above matches your Ubuntu release codename (jammy). A typo will make apt think it’s talking to a dead server.
4. Install VirtualBox 6.1
sudo apt install virtualbox-6.1
The package pulls in all necessary dependencies (kernel modules, graphics support, etc.) automatically.
Why it matters: Installing the full package keeps you from hunting down missing components later on.
5. Build Kernel Modules
After an upgrade to a new kernel (e.g., after apt dist-upgrade), the pre‑compiled VirtualBox modules may no longer match. Rebuild them with:
sudo /sbin/vboxconfig
or, if that fails, try the lower‑level command:
sudo modprobe vboxdrv
Why it matters: A mismatched module will cause “VBoxDrv cannot be loaded” errors every time you start a VM. Rebuilding fixes this instantly.
6. Verify Installation
Run VirtualBox from the Activities search or via virtualbox. The splash screen should show version 6.1.x and the kernel module status should read “Running.”
If you still see a “module not found” message, double‑check that the correct kernel headers are installed (sudo apt install linux-headers-$(uname -r)).
A Real‑World Glitch:
After upgrading from Ubuntu 20.04 to 22.04, one user reported that VirtualBox started throwing random “VBOXERROR: Driver not loaded” messages. The culprit was a missing linux-headers package for the new kernel version. Installing those headers and running /sbin/vboxconfig solved it in under five minutes.
VirtualBox 6.1 works smoothly on Ubuntu 22.04 once you follow these steps—no extra plugins, no manual module compilation (unless you’re on a custom kernel).