The simplest way to install VirtualBox on Ubuntu is sudo apt install virtualbox from the Ubuntu repositories. If you want the newest 7.x release straight from Oracle, add the official VirtualBox apt repository and install the versioned package instead. Either way you also need kernel headers, and on machines with Secure Boot you must sign the kernel modules or VirtualBox will not start virtual machines.
This guide covers both methods on current Ubuntu LTS releases (22.04, 24.04 and later), the Extension Pack, Guest Additions, Secure Boot, and the most common errors.
VirtualBox runs virtual machines using your CPU's hardware virtualization, so check these first:
sudo access.Check that the CPU exposes virtualization flags:
A number greater than 0 means the CPU supports it. If it prints 0, enable VT-x or AMD-V (often called "SVM Mode") in the firmware settings.
This is the easiest and most stable option. The package lives in the multiverse/universe components, so make sure they are enabled, then install:
The package pulls in virtualbox-dkms, which builds the kernel modules for your running kernel, so the headers must be present:
The version in the Ubuntu archive is frozen for the lifetime of the release and receives security fixes only. That is fine for most uses, but it can lag behind Oracle's latest release and may lack support for the newest guest operating systems.
Use Oracle's repository when you need the newest features or a current version on an older Ubuntu LTS.
lsb_release -cs prints it):7.x with the series shown by the search:Do not install the Ubuntu virtualbox package and Oracle's package side by side. If you switch methods, remove the old one first with sudo apt remove virtualbox virtualbox-dkms.
Oracle's repository only supports releases it lists on its download page. If your new Ubuntu release is not listed yet, use Method 1 or download the .deb for the closest release.
On a machine with Secure Boot enabled, the unsigned vboxdrv module is rejected. Symptoms are the error "Kernel driver not installed (rc=-1908)" or VMs refusing to start. The installer normally prompts you to create a Machine Owner Key (MOK) password. Do this:
You should see vboxdrv, vboxnetflt and vboxnetadp loaded. If they are missing, rebuild the modules:
Alternatively, disable Secure Boot in the firmware, which is simpler but less secure.
To let your user access USB devices passed through to guests, join the vboxusers group and log out and in again:
The Oracle VirtualBox Extension Pack adds USB 2.0/3.0, disk encryption and remote desktop support. It is a separate download whose version must match your VirtualBox version exactly, and it uses a different license (free for personal use and evaluation, not for most commercial use). Install it with:
Replace <version> with the downloaded file's version. Inside guests, install Guest Additions for shared clipboard, shared folders and automatic screen resizing. On an Ubuntu guest that is sudo apt install virtualbox-guest-utils virtualbox-guest-x11, or use Devices, Insert Guest Additions CD Image for other guests.
Confirm the install and launch the GUI:
To update, run sudo apt update && sudo apt upgrade. To remove VirtualBox:
Your virtual machines stay in ~/VirtualBox VMs unless you delete them.
The Ubuntu package is simpler and tied to the distribution's update cycle. Oracle's package gives you the latest version and fixes sooner. Pick Oracle's if you need a recent guest OS or newer features.
The kernel modules are not loaded. Install the headers and dkms, rebuild with sudo apt install --reinstall virtualbox-dkms, and if Secure Boot is on, enroll the MOK key as described above.
Modern VirtualBox can coexist with KVM by using the KVM backend, but performance can drop and some features are limited. For best results run one hypervisor at a time.
VirtualBox itself is open source under the GPLv3. The Extension Pack has a separate license (PUEL) that restricts commercial use.
Install VirtualBox on Ubuntu with sudo apt install virtualbox for a stable build, or add Oracle's apt repository for the newest 7.x release. Install kernel headers and dkms, enroll a MOK key if Secure Boot is on, add yourself to vboxusers, and match the Extension Pack version to your VirtualBox version.