How To

How To Install VirtualBox on Ubuntu 26.04 LTS

Check three things before you install VirtualBox on Ubuntu. The CPU has to expose VT-x or AMD-V, Secure Boot has to be off or ready for a signed module, and headers for the running kernel have to be installed. All three decide whether the vboxdrv kernel module loads, and when it does not, every VM you start dies with exit code 1.

Original content from computingforgeeks.com - post 5419

This guide adds Oracle’s apt repository, installs the package and creates a first VM from the command line with VBoxManage. It ends with the exact errors we hit, including the one that shows up on the first boot after a kernel update. We’d use Oracle’s repository over Ubuntu’s multiverse package because it ships the current point release the day Oracle publishes it. Every command below was run on Ubuntu 26.04.1 LTS with VirtualBox 7.2.22 in October 2026, on a headless lab VM, so the outputs are real.

Check CPU Virtualization, Secure Boot and Kernel Headers

VirtualBox needs hardware virtualization from the CPU, so start by counting the vmx (Intel) or svm (AMD) flags. A count of zero means virtualization is switched off in the firmware, or you’re inside a VM whose hypervisor does not pass it through, and no VirtualBox setting fixes that from inside Ubuntu:

grep -cE "vmx|svm" /proc/cpuinfo

Any count above zero passes. Our 4 vCPU lab VM printed 8, and the number is not a thread count. On Intel CPUs the kernel prints both a flags and a vmx flags line per CPU, and AMD CPUs get only the flags line (see the kernel source that prints them). Proxmox only exposed VT-x because the VM used the host CPU type, so set that first if you’re testing nested inside another hypervisor:

8

To see where the 8 comes from on an Intel box, count the two line types separately:

grep -E "^(flags|vmx flags)" /proc/cpuinfo | cut -d: -f1 | sort | uniq -c

Four of each on four vCPUs, so two matching lines per thread:

      4 flags
      4 vmx flags

Stock Ubuntu also loads the KVM modules at boot. Older guides told you to unload or blacklist kvm_intel before running VirtualBox, so it is worth seeing what you have now and coming back to it after the first VM starts:

lsmod | grep -E "^kvm"

Both modules are loaded and nothing is using them yet (use count 0). Note that number, because it changes once a VirtualBox VM is running:

kvm_intel             552960  0
kvm                  1527808  1 kvm_intel

Secure Boot matters because the VirtualBox modules are built on your machine, so no distribution key has signed them. The VirtualBox installation manual says UEFI systems with Secure Boot may need the VirtualBox kernel modules signed before they load. This check prints the Secure Boot state on UEFI and a plain message on BIOS machines:

ls /sys/firmware/efi 2>/dev/null >/dev/null && (mokutil --sb-state 2>&1) || echo "BIOS boot, no Secure Boot"

Our lab VM boots with BIOS, so it printed the fallback line and module signing never came into play.

BIOS boot, no Secure Boot

If yours says SecureBoot enabled, expect a MOK enrollment step after the install. Oracle’s vboxdrv.sh script signs the modules itself with /var/lib/shim-signed/mok/MOK.der and MOK.priv, or creates that key with update-secureboot-policy --new-key and queues it with --enroll-key, which asks for a one-time password. You then reboot, enroll the key in MokManager with that password, and rerun sudo /sbin/vboxconfig. Our lab boots with BIOS, so we did not test this path. Last, confirm headers exist for the kernel you are running, because the module build needs them:

dpkg -l "linux-headers-$(uname -r)" | tail -1

An ii line means the headers are installed. Our cloud image already had them through the linux-headers-virtual metapackage, which depends on linux-headers-generic and so pulls in new headers with every kernel update. If the line is missing, install headers for the running kernel plus the metapackage before going on, with sudo apt install linux-headers-$(uname -r) linux-headers-generic. Ours was already there:

ii  linux-headers-7.0.0-15-generic 7.0.0-15.15  amd64        Linux kernel headers for version 7.0.0

So the box you are about to install on should have these:

  • A non-zero vmx/svm count
  • Secure Boot off, or a plan to enroll a MOK key
  • linux-headers-$(uname -r) installed
  • About 1.1 GB of free disk for the package and its build tools

If any of these fails, fix it now. Each one turns into the same vague startup error later, and it is much harder to tell them apart from there.

Add the Oracle VirtualBox Repository

Ubuntu ships VirtualBox in multiverse, and Oracle runs its own apt repository with a suite for each Ubuntu codename. On the day we tested, the two were far apart:

SourcePackageCandidate versionTested here
Ubuntu multiversevirtualbox, virtualbox-dkms7.2.6-dfsg-4No (candidate checked only)
Oracle repositoryvirtualbox-7.27.2.22-175245~Ubuntu~resoluteYes

Multiverse was a long run of maintenance releases behind, so we’d use Oracle’s repo on anything you run every day. The multiverse package is the pick only when you want everything to come from Ubuntu’s archive and can live with a lag; sudo apt install virtualbox installs it, but we did not run that path in this lab. Import Oracle’s signing key into its own keyring file first, so the key is trusted only for this one repository.

curl -fsSL https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor

The --yes flag lets you rerun the command without gpg refusing to overwrite the file. Check the fingerprint before you trust the key:

gpg --show-keys --with-fingerprint /usr/share/keyrings/oracle-virtualbox-2016.gpg

It must read B9F8 D658 297A F3EF C18D 5CDF A2F6 83C5 2980 AECF, the fingerprint Oracle publishes on its Linux downloads page. If it differs, delete the file and stop:

pub   rsa4096 2016-04-22 [SC]
      B9F8 D658 297A F3EF C18D  5CDF A2F6 83C5 2980 AECF
uid                      Oracle Corporation (VirtualBox archive signing key) <[email protected]>

Now create the source in the deb822 format that current Ubuntu releases use for apt sources.

sudo vim /etc/apt/sources.list.d/virtualbox.sources

Paste this file. resolute is the Ubuntu 26.04 codename, and Oracle’s dists/ listing also has a noble suite for 24.04, though we only ran the 26.04 one:

Types: deb
URIs: https://download.virtualbox.org/virtualbox/debian
Suites: resolute
Components: contrib
Architectures: amd64
Signed-By: /usr/share/keyrings/oracle-virtualbox-2016.gpg

Refresh the package index and list the VirtualBox packages the new source offers.

sudo apt-get update
apt-cache search --names-only "^virtualbox-7"

Apt fetched the resolute InRelease file with no signature warning, and two branches are available. Take virtualbox-7.2. The 7.1 line still fights with KVM on kernel 6.12 and newer, where it needs kvm.enable_virt_at_load=0 on the kernel command line or the KVM module unloaded, per the 7.1 changelog:

Get:2 https://download.virtualbox.org/virtualbox/debian resolute InRelease [4442 B]
Get:6 https://download.virtualbox.org/virtualbox/debian resolute/contrib amd64 Packages [1480 B]
virtualbox-7.1 - Oracle VirtualBox
virtualbox-7.2 - Oracle VirtualBox

A NO_PUBKEY error at this point means the Signed-By path does not match the keyring file you created, so compare the two before going further.

Install VirtualBox on Ubuntu

The package pulls in the compiler toolchain it needs to build its kernel modules on your machine, which is why the install is much bigger than the VirtualBox binaries alone.

sudo apt install virtualbox-7.2

On our minimal server image apt reported 304 new packages, including gcc-15 and make, and the install took 3 minutes 13 seconds:

0 upgraded, 304 newly installed, 0 to remove and 4 not upgraded.
Need to get 324 MB of archives.
After this operation, 1098 MB of additional disk space will be used.

The install is only done when the kernel module is loaded, because a package that installed cleanly can still have failed its module build. Confirm the version, then check the service and the modules:

VBoxManage --version
systemctl is-active vboxdrv
lsmod | grep -i vbox

You want the version string, active, and three modules. vboxdrv is the core driver; vboxnetflt and vboxnetadp handle bridged and host-only networking:

7.2.22r175245
active
vboxnetadp             28672  0
vboxnetflt             40960  0
vboxdrv               737280  2 vboxnetadp,vboxnetflt

Apt also registers four systemd units. Only the first matters for a basic setup, and it is the one that rebuilds modules after kernel updates:

  • vboxdrv.service: builds and loads the kernel modules
  • vboxautostart-service.service: starts VMs at boot
  • vboxballoonctrl-service.service: guest memory ballooning
  • vboxweb-service.service: the SOAP web service

If lsmod prints nothing, the build failed or the module was refused (Secure Boot is the usual cause), and the first VM you start will fail. Jump to the troubleshooting section before going further. The package also ships the VirtualBox Manager GUI for desktop installs, but our lab had no display, so we didn’t test it; everything below uses VBoxManage, which works the same on desktops and servers.

Create a Headless VM with VBoxManage

A small ISO is enough to prove the hypervisor works. Alpine’s virt image is 66 MB, and this pulls the current release name from Alpine’s own release file instead of hardcoding it:

V=$(curl -s https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/latest-releases.yaml | grep -oE "alpine-virt-[0-9.]+-x86_64.iso" | head -1)
echo $V
curl -sSfLo ~/$V https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/$V

The echo should print a single filename such as alpine-virt-3.24.2-x86_64.iso. If it prints nothing, the release file moved and the download will fail, so check the variable before you go on. Create and register the VM next.

VBoxManage createvm --name alpine01 --ostype Linux_64 --register

VirtualBox writes the VM definition under ~/VirtualBox VMs/ in your home directory, which is also where its logs land. VMs belong to the user who created them, so run every later VBoxManage command as that same user and not with sudo:

Virtual machine 'alpine01' is created and registered.
UUID: bd49d29c-1dc7-47e9-9954-e510d8a23be5
Settings file: '/home/josphat/VirtualBox VMs/alpine01/alpine01.vbox'

Give it 512 MB of RAM, one CPU and NAT networking, add an IDE controller, and attach the ISO as a DVD drive. NAT needs no host network changes, so it is the right default for a first VM:

ISO=$(ls ~/alpine-virt-*.iso)
VBoxManage modifyvm alpine01 --memory 512 --cpus 1 --nic1 nat --graphicscontroller vmsvga
VBoxManage storagectl alpine01 --name IDE --add ide
VBoxManage storageattach alpine01 --storagectl IDE --port 0 --device 0 --type dvddrive --medium "$ISO"

On a server you cannot see the guest’s screen, so send its serial console to a file. This is how we confirmed the guest actually booted instead of trusting the start message:

VBoxManage modifyvm alpine01 --uart1 0x3F8 4 --uart-mode1 file /tmp/alpine01-serial.log

Adding --type headless starts the VM without a window, which is the only way it runs on a server with no display. It also works on a desktop when you want a VM in the background:

VBoxManage startvm alpine01 --type headless

VBoxManage returns as soon as the VM process is up. That message only says the process started, not that the guest booted, so it proves less than it looks like it does:

Waiting for VM "alpine01" to power on...
VM "alpine01" has been successfully started.

Give it about 20 seconds and read the serial log. A login prompt there is the real proof that the guest kernel ran under VirtualBox:

grep -aE "Welcome to Alpine|login:" /tmp/alpine01-serial.log

Our guest reached its login prompt 22 seconds after a cold start, and 18 seconds on later runs. No key press was needed at the boot menu, so the same check works unattended in a script:

Welcome to Alpine Linux 3.24
localhost login:

A screenshot of the VGA console with VBoxManage controlvm alpine01 screenshotpng was less useful. It stayed on the ISOLINUX boot: screen even after the guest had booted, because Alpine’s virt kernel never redrew the VGA console after the boot menu. Use the serial file for any guest you run headless. When you have seen the prompt, power it off.

VBoxManage controlvm alpine01 poweroff

From here the VM grows like any other, and our guide to adding an extra disk to a VirtualBox VM covers the next step most people need. If you build VMs from code, Vagrant on Ubuntu can drive this same VirtualBox install as its provider.

Run VirtualBox Alongside KVM

On VirtualBox 7.2.2 or later with kernel 6.16 or newer, you do not need to unload kvm_intel, because 7.2.2 switched Linux hosts to the KVM APIs for acquiring and releasing VT-x (see the 7.2 changelog). With both KVM modules loaded and enable_virt_at_load set to Y, the VM above started normally, and its VBox.log shows VirtualBox using VT-x itself. While the VM ran, the kvm_intel use count went from 0 to 2:

VirtualBox headless VM running on Ubuntu 26.04 with kvm_intel loaded, VBox.log shows VT-x and VMXON

The lines to look for are HM: HMR3Init: VT-x w/ nested paging and HM: Using VT-x implementation 3.0, which mean hardware virtualization, not the slow fallback. Run the same check on your own VM’s log.

grep -iE "HM: HMR3Init|VT-x|AMD-V|NEM|execution engine" ~/"VirtualBox VMs/alpine01/Logs/VBox.log" | head -15

Our test covered one VirtualBox VM with KVM loaded but idle. We did not run a QEMU/KVM guest at the same time, so if you also use KVM and virt-manager on the same host, test that combination before you depend on it. To move a disk between the two, convert the VDI to qcow2 instead of running both hypervisors side by side.

Install the VirtualBox Extension Pack

The Extension Pack must match the installed version exactly, so take the version from VBoxManage and build the download URL from it. That keeps the command correct after every upgrade:

V=$(VBoxManage --version | cut -dr -f1)
curl -sSfLo /tmp/Oracle_VirtualBox_Extension_Pack-$V.vbox-extpack https://download.virtualbox.org/virtualbox/$V/Oracle_VirtualBox_Extension_Pack-$V.vbox-extpack

Oracle’s license appears first and the installer waits for y. Piping yes accepts it, so read the license first if you are installing for an organization, because the Extension Pack is under Oracle’s PUEL, not the GPL. The PUEL covers only personal non-commercial use by the person who downloaded it and curriculum use at academic institutions. Any use by or for a business, organization, government or educational institution needs Oracle’s paid Extension Pack Enterprise License, as the licensing FAQ explains:

yes | sudo VBoxManage extpack install --replace /tmp/Oracle_VirtualBox_Extension_Pack-$V.vbox-extpack
VBoxManage list extpacks

Installation succeeded, and the description line lists just two features:

Successfully installed "Oracle VirtualBox Extension Pack".
Extension Packs: 1
Pack no. 0:   Oracle VirtualBox Extension Pack
Version:        7.2.22
Revision:       175245
Edition:
Description:    Oracle Cloud Infrastructure integration, PXE ROM.

That short list is why many people can skip the pack now. Oracle has been moving features into the open source base package, starting with the EHCI and XHCI (USB 2 and USB 3) controllers in 7.0, according to the VirtualBox 7.0 changelog. NVMe followed in 7.2.0 and the USB webcam in 7.2.2, then VRDP, USB smartcard emulation and disk and VM encryption in 7.2.6. Install the pack if you need PXE boot or Oracle Cloud integration. USB passthrough also needs your user in the vboxusers group per the manual; our lab user was not in it, and we did not test USB devices.

Troubleshoot VirtualBox Errors on Ubuntu

All three errors below come from the same cause: vboxdrv isn’t loaded at the moment you start a VM. They look different depending on when you hit them, so each one gets its own entry with what we saw and what fixed it.

WARNING: The vboxdrv kernel module is not loaded

This warning prints when the module was never built for the running kernel or failed to load, and it names the kernel it looked for. We reproduced it by stopping vboxdrv, which leaves you in the same state as booting a new kernel that has no headers. The fix the warning suggests is the right one, since vboxconfig rebuilds the modules against the running kernel and loads them:

VirtualBox vboxdrv kernel module not loaded error NS_ERROR_FAILURE fixed with sudo /sbin/vboxconfig on Ubuntu 26.04

On our 4 vCPU box the rebuild took 32 seconds. Run it as root, because it writes modules under /lib/modules and restarts the VirtualBox services.

sudo /sbin/vboxconfig

If vboxconfig itself fails, check the headers with the dpkg -l command from the first section, because a missing linux-headers-$(uname -r) package is the usual reason it can’t build. On a Secure Boot machine, a build that succeeds but still won’t load points at an unsigned module.

terminated unexpectedly during startup with exit code 1 (0x1), NS_ERROR_FAILURE

These two lines follow the warning above. A GUI dialog or a script log may show only them, without the warning, so they’re worth knowing on their own:

VBoxManage: error: The virtual machine 'alpine01' has terminated unexpectedly during startup with exit code 1 (0x1)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine

NS_ERROR_FAILURE (0x80004005) is a generic failure code, so on its own it does not tell you much. Check the module first, since that’s what caused every instance we saw:

systemctl is-active vboxdrv
lsmod | grep -c "^vbox"

Healthy is active and 3. A count of 0 means run sudo /sbin/vboxconfig; activating means the module is still being built, which is the next case.

VM fails on the first boot after a kernel update

This one looks like a broken install but is not. Our lab rebooted into a newer kernel that cloud-init had installed with an apt-get dist-upgrade at first boot (304 seconds, per /var/log/cloud-init.log and the apt history), and vboxdrv.service rebuilt the modules during boot. We started the VM right after logging in, while the service still read activating, and got the same exit code 1 and NS_ERROR_FAILURE. The journal shows what it was doing:

sudo journalctl -b -u vboxdrv --no-pager -o short-precise | tail -8
systemd-analyze blame | grep -i vbox

Building modules for the new kernel kept the unit busy for 22 seconds before it reported started:

Oct 21 10:10:42.777535 vbox01 systemd[1]: Starting vboxdrv.service - VirtualBox Linux kernel module...
Oct 21 10:10:43.963959 vbox01 vboxdrv.sh[922]: vboxdrv.sh: Starting VirtualBox services.
Oct 21 10:10:44.103867 vbox01 vboxdrv.sh[922]: vboxdrv.sh: Building VirtualBox kernel modules.
Oct 21 10:11:05.015187 vbox01 systemd[1]: Started vboxdrv.service - VirtualBox Linux kernel module.
22.237s vboxdrv.service

Once systemctl is-active vboxdrv printed active, the same VM booted to its login prompt in 18 seconds with no other change. So after any kernel update, wait for that active before you start VMs, and if you launch VMs from your own systemd units or scripts, order them after vboxdrv.service. It worked here because the linux-headers-generic metapackage had already installed headers for the new kernel; without them, the boot-time build fails and you’re back at the first error.

VT-x conflict with KVM did not happen

Many older answers blame a VT-x conflict with KVM for startup failures and tell you to blacklist kvm_intel. We didn’t see that error at all: VirtualBox ran with KVM loaded, as the earlier section shows. That holds for the 7.2 package on this kernel; on virtualbox-7.1 the conflict is real and needs kvm.enable_virt_at_load=0. If a VM fails on the 7.2 line, check vboxdrv before you touch KVM. On Fedora or Rocky hosts the steps differ, and our guides to VirtualBox on Fedora and Rocky Linux and AlmaLinux cover them.

Keep reading

Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) Ubuntu Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Install KVM and Virt-Manager on Arch Linux Virtualization Install KVM and Virt-Manager on Arch Linux Upgrade a Single Package on Ubuntu / Debian with apt Debian Upgrade a Single Package on Ubuntu / Debian with apt APT Cheat Sheet: apt and apt-get Commands for Ubuntu/Debian Cheat Sheets APT Cheat Sheet: apt and apt-get Commands for Ubuntu/Debian How To Install Java on Ubuntu 24.04 Ubuntu How To Install Java on Ubuntu 24.04

25 thoughts on “How To Install VirtualBox on Ubuntu 26.04 LTS”

  1. Hello,
    I am getting the following error:
    E: The repository ‘http://download.virtualbox.org/virtualbox/debian vera Release’ does not have a Release file.
    N: Updating from such a repository can’t be done securely, and is therefore disabled by default.

    Any suggestion?
    System:
    Kernel: 5.15.0-69-generic x86_64 bits: 64 compiler: gcc v: 11.3.0 Desktop: MATE 1.26.0 wm: marco
    dm: LightDM Distro: Linux Mint 21.1 Vera base: Ubuntu 22.04 jammy

    Reply
  2. Nicely written instructions, but I wonder if something has changed. It all goes very well until…

    root@dbsxxx:~# sudo apt install virtualbox-7.0
    Reading package lists… Done
    Building dependency tree… Done
    Reading state information… Done
    E: Unable to locate package virtualbox-7.0
    E: Couldn’t find any package by glob ‘virtualbox-7.0’

    Reply
  3. Hello, Josaphat!

    Could you please tip me.
    I’m trying to install virtualbox 7.0 on fresh Ubuntu 20.04

    The following packages have unmet dependencies:
    virtualbox-7.0 : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.14 is to be installed
    Depends: libqt5core5a (>= 5.15.1) but 5.12.8+dfsg-0ubuntu2.1 is to be installed
    Depends: libqt5dbus5 (>= 5.14.1) but 5.12.8+dfsg-0ubuntu2.1 is to be installed
    Depends: libqt5gui5 (>= 5.14.1) but 5.12.8+dfsg-0ubuntu2.1 is to be installed or
    libqt5gui5-gles (>= 5.14.1) but it is not going to be installed
    Depends: libqt5help5 (>= 5.15.1) but it is not going to be installed
    Depends: libqt5widgets5 (>= 5.15.1) but 5.12.8+dfsg-0ubuntu2.1 is to be installed
    Depends: libssl3 (>= 3.0.0~~alpha1) but it is not installable
    Depends: libstdc++6 (>= 12) but 10.5.0-1ubuntu1~20.04 is to be installed
    Depends: libvpx7 (>= 1.10.0) but it is not installable
    Recommends: libsdl-ttf2.0-0 but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.

    Reply

Leave a Comment

Press ESC to close