VirtualBox is an open-source virtualization platform that runs multiple operating systems simultaneously on a single host machine. Whether you are testing different Linux distributions, running Windows applications through virtualization, developing cross-platform software, or creating isolated environments for security testing, VirtualBox provides flexibility to manage diverse virtual machines without dual-booting or maintaining separate physical hardware.
This guide covers importing Oracle’s official repository from the VirtualBox Linux Downloads page, installing VirtualBox with matching kernel headers, configuring the Extension Pack for USB 3.0 and RDP support, and setting user group permissions for hardware access. You will complete the setup from repository configuration through a production-ready virtualization environment with automatic security updates.
This guide covers Ubuntu 22.04 LTS (Jammy) and 24.04 LTS (Noble). Oracle’s VirtualBox repository does not yet provide packages for Ubuntu 26.04 LTS (Resolute). Once Oracle adds a dedicated branch for 26.04, this guide will be updated. Until then, Ubuntu 26.04 users should install the
virtualboxpackage from Ubuntu’s default repositories usingsudo apt install virtualboxinstead of following the repository setup below.
Import VirtualBox APT Repository
Update System and Install Repository Tools
First, update your system before installing VirtualBox to ensure kernel headers and dependencies match your current kernel version. This prevents module compilation failures when VirtualBox builds its kernel drivers.
Start by updating the package list to refresh repository metadata:
sudo apt update
Then upgrade installed packages to their latest versions:
sudo apt upgrade
Install Repository Management Tools
Next, install the tools required for repository management and GPG key handling. Standard Ubuntu desktop installations include most of these packages, but minimal installations, cloud images, or WSL environments may lack them:
sudo apt install curl ca-certificates gpg lsb-release -y
The gpg package converts Oracle’s ASCII-armored key to binary format, while lsb-release provides the lsb_release -cs command used to detect your Ubuntu codename automatically.
Import VirtualBox GPG Key
Afterward, import Oracle’s GPG key to verify package authenticity. APT uses this key to confirm VirtualBox packages come from Oracle’s official repository and haven’t been tampered with during download:
curl -fSsL https://www.virtualbox.org/download/oracle_vbox_2016.asc | gpg --dearmor | sudo tee /usr/share/keyrings/virtualbox.gpg > /dev/null
Add VirtualBox Repository
Now add the official VirtualBox repository to your system. The $(lsb_release -cs) variable automatically detects your Ubuntu codename (jammy for 22.04, noble for 24.04) so the command works across supported releases:
cat <<EOF | sudo tee /etc/apt/sources.list.d/virtualbox.sources
Types: deb
URIs: http://download.virtualbox.org/virtualbox/debian
Suites: $(lsb_release -cs)
Components: contrib
Architectures: $(dpkg --print-architecture)
Signed-By: /usr/share/keyrings/virtualbox.gpg
EOF
This configuration uses the modern DEB822 repository format with GPG key verification. Ubuntu fully supports this format and it prevents duplicate repository entries.
Refresh the package index to include VirtualBox packages from the newly added repository:
sudo apt update
Install VirtualBox via APT Command
Install VirtualBox and Kernel Headers
Now install VirtualBox 7.2 with the build tools and kernel headers required to compile its kernel modules (vboxdrv, vboxnetflt, vboxnetadp). The linux-headers-$(uname -r) package matches your running kernel, while build-essential and dkms handle module compilation:
sudo apt install virtualbox-7.2 build-essential dkms linux-headers-$(uname -r) -y
Oracle’s repository also provides
virtualbox-7.1andvirtualbox-7.0if you need an older version for compatibility reasons. Replace the package name in the command above to install a different version.
Verify Installation Source
After installation, confirm VirtualBox installed from Oracle’s repository rather than Ubuntu’s default repositories (which contain older versions). The output shows the installed version, candidate version, and repository source:
apt-cache policy virtualbox-7.2
Expected output confirming installation from Oracle’s repository:
virtualbox-7.2:
Installed: 7.2.4-170995~Ubuntu~noble
Candidate: 7.2.4-170995~Ubuntu~noble
Version table:
*** 7.2.4-170995~Ubuntu~noble 500
500 http://download.virtualbox.org/virtualbox/debian noble/contrib amd64 Packages
100 /var/lib/dpkg/status
The output confirms the package source is download.virtualbox.org rather than Ubuntu’s default repositories. The version suffix (~Ubuntu~noble or ~Ubuntu~jammy) reflects your Ubuntu release.
Check VirtualBox Service Status
Next, verify the vboxdrv systemd service loaded successfully. This service manages VirtualBox kernel modules (vboxdrv, vboxnetflt, vboxnetadp) that handle virtualization, networking, and host-only adapters:
systemctl status vboxdrv
Expected output showing successful kernel module loading:
● vboxdrv.service - VirtualBox Linux kernel module
Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; preset: enabled)
Active: active (exited) since Thu 2026-01-01 11:00:00 UTC; 5min ago
Process: 1234 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=0/SUCCESS)
Main PID: 1234 (code=exited, status=0/SUCCESS)
CPU: 1.234s
The active (exited) status with status=0/SUCCESS confirms the kernel modules loaded correctly during installation.
If Secure Boot is enabled and the service reports signature or verification errors, enroll the DKMS key so the modules load. Run
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der, set a one-time password, reboot, choose Enroll MOK at the blue screen, and enter the password. After enrollment, rerunsystemctl status vboxdrvto confirm the modules load.
Enable VirtualBox Service (If Required)
If that vboxdrv service shows inactive status, enable it to load kernel modules automatically at boot:
sudo systemctl enable vboxdrv --now
Add User to vboxusers Group
Before launching VirtualBox and creating virtual machines, add your user account to the vboxusers group. This grants access to USB devices, network interfaces, and other hardware features required for full virtualization functionality. Without this group membership, VirtualBox cannot pass through USB devices or configure bridged networking:
sudo usermod -a -G vboxusers $USER
Log out and log back in (or reboot) for group membership changes to take effect. Verify your user now belongs to the vboxusers group:
groups $USER
Expected output showing vboxusers group membership:
username : username adm cdrom sudo dip plugdev lpadmin sambashare vboxusers
If vboxusers does not appear in the output, reboot your system to complete the group membership update. Group changes only take effect in new login sessions.
Launch VirtualBox
Launch VirtualBox from the terminal with a single command:
virtualbox
Alternatively, open VirtualBox from your desktop environment by clicking Activities at the top of your screen, selecting Show Applications, and choosing Oracle VM VirtualBox from the list.

Install VirtualBox Extension Pack (Optional)
The VirtualBox Extension Pack enhances virtual machine functionality with practical features: USB 3.0 support for external drives and devices, RDP (Remote Desktop Protocol) for headless VM access, disk encryption for sensitive data, NVMe storage support, and PXE boot for Intel network cards. Install this pack only if you need external hardware passthrough or remote VM access. The pack requires separate licensing (proprietary components), but Oracle provides it free for personal and evaluation use.
Download VirtualBox Extension Pack
To proceed, download the Extension Pack matching your installed VirtualBox version. First, check your VirtualBox version:
vboxmanage -v | cut -dr -f1
This command returns your version number (for example, 7.2.4). Store the version in a variable to download the matching Extension Pack without manual URL editing:
VBOX_VERSION=$(vboxmanage -v | cut -dr -f1)
wget https://download.virtualbox.org/virtualbox/${VBOX_VERSION}/Oracle_VM_VirtualBox_Extension_Pack-${VBOX_VERSION}.vbox-extpack
Install VirtualBox Extension Pack
Once downloaded, install or upgrade the Extension Pack:
sudo vboxmanage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-${VBOX_VERSION}.vbox-extpack
During installation, you’ll be prompted to accept Oracle’s Personal Use and Evaluation License (PUEL). Type y and press Enter to accept.
Verify Extension Pack Installation
Confirm the Extension Pack installed successfully and matches your VirtualBox version:
vboxmanage list extpacks
Expected output showing the Extension Pack is installed and active:
Extension Packs: 1 Pack no. 0: Oracle VM VirtualBox Extension Pack Version: 7.2.4 Revision: 170995 Edition: Description: Oracle Cloud Infrastructure integration, USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe, full VM encryption. VRDE Module: VBoxVRDP Crypto Module: VBoxPuelCrypto Usable: true Why unusable:
Install Guest Additions Inside Virtual Machines (Optional)
Guest Additions is additional software you install inside each virtual machine (not on the host) to enhance VM performance. It provides shared clipboard, drag-and-drop file transfers between host and guest, shared folders for seamless file access, automatic screen resolution adjustment, and improved video rendering. Install Guest Additions after creating and launching your first virtual machine. The installation process differs slightly between Linux and Windows guests.
Install Guest Additions on Linux Virtual Machines
Inside your Linux guest VM, first install the required build tools and kernel headers needed to compile Guest Additions modules:
sudo apt install build-essential dkms linux-headers-$(uname -r)
Next, mount the Guest Additions ISO from the VirtualBox menu. Click Devices at the top of the VM window, then select Insert Guest Additions CD image. VirtualBox automatically mounts the ISO to your VM:
cd /media/$USER/VBox_GAs_* && sudo sh ./VBoxLinuxAdditions.run
The mount path may vary depending on your Linux distribution. If the path above does not exist, run
ls /media/$USER/to find the actual Guest Additions CD mount point, which typically containsVBox_GAsfollowed by the version number.
The installer compiles kernel modules and displays progress. After completion, reboot the guest to activate Guest Additions features:
sudo reboot
Install Guest Additions on Windows Virtual Machines
Inside your Windows guest VM, click Devices from the VirtualBox menu bar, then select Insert Guest Additions CD image. Windows automatically detects and mounts the ISO. The VirtualBox Guest Additions installer should launch automatically; if not, open File Explorer, navigate to the CD drive, and double-click VBoxWindowsAdditions.exe to start the installer.
Follow the on-screen prompts to complete the installation. When prompted, accept the default installation settings. The installer may request administrative privileges and ask you to reboot the guest system after completion. Reboot Windows to fully activate Guest Additions features.
Verify Guest Additions Installation
After rebooting your guest (Linux or Windows), verify Guest Additions installed successfully. On Linux, check the kernel module status:
lsmod | grep vboxguest
The output should show vboxguest as a loaded kernel module, confirming successful installation. On Windows, open VirtualBox Guest Additions from the Control Panel or System Tray to verify the installed version.
Test Guest Additions Features
With Guest Additions installed, test the enhanced features. For example, try dragging a file from your host desktop into the guest VM window; the file should transfer directly without requiring external transfer tools. Test shared clipboard by copying text on the host and pasting it into the guest, or vice versa. If you configured shared folders, open File Manager on Linux or File Explorer on Windows and navigate to the shared folder to confirm seamless host-guest file access.
Troubleshooting VirtualBox Installation
Unable to Locate Package dkms or build-essential
If you see E: Unable to locate package dkms or similar errors for build-essential during installation, your system is missing access to Ubuntu’s main and universe repositories. This can happen on fresh installations where the APT sources configuration file is missing or incomplete.
First, check if the Ubuntu sources file exists:
ls -la /etc/apt/sources.list.d/ubuntu.sources
If the file is missing but a backup exists (created during installation), restore it:
sudo cp /etc/apt/sources.list.d/ubuntu.sources.curtin.orig /etc/apt/sources.list.d/ubuntu.sources
If no backup exists, create a minimal sources file that enables the main repositories:
CODENAME=$(lsb_release -cs)
cat <<EOF | sudo tee /etc/apt/sources.list.d/ubuntu.sources
Types: deb
URIs: http://archive.ubuntu.com/ubuntu
Suites: $CODENAME ${CODENAME}-updates ${CODENAME}-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
After restoring or creating the sources file, update the package index and retry the installation:
sudo apt update
sudo apt install virtualbox-7.2 build-essential dkms linux-headers-$(uname -r) -y
vboxdrv Kernel Module Fails to Load
If the vboxdrv service fails to start after installation, the kernel modules may not have compiled correctly. First, check if the required headers are installed for your running kernel:
dpkg -l | grep linux-headers-$(uname -r)
If nothing appears, install the matching headers and rebuild the VirtualBox modules:
sudo apt install linux-headers-$(uname -r)
sudo /sbin/vboxconfig
Then verify the service is running:
systemctl status vboxdrv
Repository Does Not Have a Release File (Ubuntu 26.04)
If you see the error The repository 'http://download.virtualbox.org/virtualbox/debian resolute Release' does not have a Release file during apt update, your Ubuntu version (26.04 LTS) is not yet supported by Oracle’s VirtualBox repository. This occurs because Oracle adds repository branches for new Ubuntu releases after they are officially released, and 26.04 support has not yet been added.
To resolve this, remove the Oracle repository and install from Ubuntu’s default repositories instead:
sudo rm /etc/apt/sources.list.d/virtualbox.sources /usr/share/keyrings/virtualbox.gpg
sudo apt update
sudo apt install virtualbox -y
The Ubuntu-packaged version may be slightly older than Oracle’s latest release but remains fully functional. Once Oracle adds repository support for Ubuntu 26.04, this guide will be updated with instructions to switch to the official repository for the latest features.
Remove VirtualBox
If VirtualBox is no longer needed, remove it while preserving your virtual machine files. If you installed the Extension Pack, uninstall it first to clean up the proprietary components:
sudo vboxmanage extpack uninstall "Oracle VM VirtualBox Extension Pack"
To remove the package while keeping configuration:
sudo apt remove virtualbox-7.2
To remove VirtualBox completely including configuration files (while preserving virtual machines stored in ~/VirtualBox VMs), use purge:
sudo apt purge virtualbox-7.2 && sudo apt autoremove
If you also want to remove the VirtualBox repository and GPG key:
sudo rm /etc/apt/sources.list.d/virtualbox.sources /usr/share/keyrings/virtualbox.gpg
Optionally remove your account from the vboxusers group if you no longer need VirtualBox hardware access:
sudo gpasswd -d $USER vboxusers
Remove Virtual Machines and Configuration (Optional)
The following commands permanently delete your virtual machines and VirtualBox configuration. This cannot be undone. Only proceed if you no longer need any VM disk images or settings.
To completely remove all VirtualBox data including virtual machines and configuration:
rm -rf ~/"VirtualBox VMs" ~/.config/VirtualBox
Conclusion
Your Ubuntu system now runs VirtualBox with Oracle’s latest features, automatic kernel module updates through DKMS, and security patches via APT. The Extension Pack enables USB 3.0 passthrough and RDP access for headless VMs, while Guest Additions inside each VM provides shared clipboard, drag-and-drop transfers, and automatic resolution scaling. Updates arrive automatically with your regular system maintenance.
perfect. thanks
amazing guide – the best I’ve seen
I would love you to add a section on how to install the guest additions in the guest os
I run into problems with installing guestadditions on the Arch VM
Thank you for this guide, it was clear and easy to follow. 🙂
Thank you for the accurate and easy-to-follow instructions.
I installed the stable version, not the nightly, but everything seems to work fine.