Debian

Install VirtualBox on Ubuntu 24.04 / Debian 13 / Kali Linux

VirtualBox is a free, open-source hypervisor from Oracle that lets you run multiple operating systems on a single machine. It supports Windows, Linux, macOS, and Solaris guests, making it a practical tool for testing, development, and lab environments without dedicated hardware.

Original content from computingforgeeks.com - post 106

This guide covers installing VirtualBox 7.2 on Ubuntu 24.04, Debian 13 (Trixie), and Kali Linux. We walk through both the distribution repository method and the Oracle repository method (which gives you the latest release), then cover the Extension Pack, Guest Additions, VM creation, and common troubleshooting steps. For official downloads and documentation, see the VirtualBox downloads page.

Prerequisites

Before starting, make sure you have the following in place:

  • A machine running Ubuntu 24.04 LTS, Debian 13, or Kali Linux (2025.x or later)
  • A user account with sudo privileges
  • At least 4 GB RAM (8 GB recommended if running VMs with graphical desktops)
  • Hardware virtualization enabled in BIOS/UEFI (Intel VT-x or AMD-V)
  • Internet access to download packages

Step 1: Install VirtualBox from Ubuntu / Debian Repositories

The quickest way to get VirtualBox running is from your distribution’s default repositories. The version available here may be slightly behind the latest Oracle release, but it integrates well with system updates and requires no extra repository configuration.

Update your package index and install VirtualBox:

sudo apt update
sudo apt install virtualbox -y

After installation completes, verify the installed version:

vboxmanage --version

The output shows the VirtualBox version number. If you need the latest release (7.2.x as of this writing), follow Step 2 instead.

Step 2: Install VirtualBox 7.2 from Oracle Repository

Oracle maintains its own apt repository with the latest VirtualBox builds. This method gives you VirtualBox 7.2.6 (the current release) and keeps it updated through apt. If you already installed VirtualBox from the distro repo in Step 1, remove it first to avoid conflicts:

sudo apt remove --purge virtualbox -y

Import the Oracle GPG key

Download and register Oracle’s signing key so apt can verify the packages:

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

Add the VirtualBox repository

Add the Oracle repository to your sources list. Replace the codename with the one matching your distribution:

  • Ubuntu 24.04noble
  • Debian 13trixie
  • Kali Linux (based on Debian testing) – use trixie

On Ubuntu 24.04:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian noble contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

On Debian 13 / Kali Linux:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian trixie contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Install VirtualBox 7.2

Update the package index to pull in the new repository, then install VirtualBox 7.2:

sudo apt update
sudo apt install virtualbox-7.2 -y

Confirm VirtualBox 7.2 is installed and working:

vboxmanage --version

You should see version 7.2.6 or later in the output:

7.2.6r172322

Step 3: Install VirtualBox Extension Pack

The Extension Pack adds USB 2.0/3.0 support, VirtualBox Remote Desktop Protocol (VRDP), disk encryption, and PXE boot for Intel cards. It is free for personal and evaluation use under the VirtualBox PUEL license.

Download the Extension Pack matching your VirtualBox version:

cd /tmp
wget https://download.virtualbox.org/virtualbox/7.2.6/Oracle_VirtualBox_Extension_Pack-7.2.6.vbox-extpack

Install it with VBoxManage:

sudo vboxmanage extpack install --replace Oracle_VirtualBox_Extension_Pack-7.2.6.vbox-extpack

Accept the license when prompted. Verify the Extension Pack is installed:

vboxmanage list extpacks

The output confirms the Extension Pack version and that it is usable:

Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      7.2.6
Revision:     172322
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: 

Clean up the downloaded file:

rm -f /tmp/Oracle_VirtualBox_Extension_Pack-7.2.6.vbox-extpack

Step 4: Add Your User to the vboxusers Group

VirtualBox requires your user account to be a member of the vboxusers group to access USB devices and host-only networking. Without this, you will get permission errors when attaching USB devices to VMs.

Add your current user to the group:

sudo usermod -aG vboxusers $USER

Log out and log back in for the group membership to take effect. You can confirm the change with:

groups $USER

The output should include vboxusers in the list of groups.

Step 5: Create Your First Virtual Machine

With VirtualBox installed, you can create a VM from the graphical interface or the command line. Here we cover both approaches.

Using the GUI

Launch VirtualBox from your application menu or run it from the terminal:

virtualbox

Click New in the toolbar. Enter a name for the VM, select the folder where VM files will be stored, and choose the ISO image for installation. VirtualBox auto-detects the OS type from the ISO name in most cases. Set the RAM and CPU count based on the guest OS requirements, then create a virtual hard disk (VDI format, dynamically allocated). Click Finish to create the VM, then Start to boot the installer.

Using the command line

If you prefer the CLI, you can create and configure a VM entirely with VBoxManage. This example creates an Ubuntu Server VM with 2 GB RAM and a 40 GB disk:

vboxmanage createvm --name "UbuntuServer" --ostype Ubuntu_64 --register
vboxmanage modifyvm "UbuntuServer" --memory 2048 --cpus 2 --nic1 nat
vboxmanage createmedium disk --filename ~/VirtualBox\ VMs/UbuntuServer/UbuntuServer.vdi --size 40960
vboxmanage storagectl "UbuntuServer" --name "SATA Controller" --add sata --controller IntelAhci
vboxmanage storageattach "UbuntuServer" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium ~/VirtualBox\ VMs/UbuntuServer/UbuntuServer.vdi
vboxmanage storageattach "UbuntuServer" --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /path/to/ubuntu-24.04-live-server-amd64.iso

Replace /path/to/ubuntu-24.04-live-server-amd64.iso with the actual path to your ISO file. Start the VM in headless mode or with a GUI window:

vboxmanage startvm "UbuntuServer" --type gui

Step 6: Configure VM Settings – Networking and Shared Folders

VirtualBox offers several networking modes. The right choice depends on whether the VM needs internet access, host communication, or both.

Networking modes

Here is a quick reference of the most common networking options:

ModeInternet AccessHost-to-VM
NATYesPort forwarding only
Bridged AdapterYesYes (own IP on LAN)
Host-OnlyNoYes (private network)
NAT NetworkYesPort forwarding (VMs can talk to each other)

To switch a VM to bridged networking (useful when you need the VM to appear as a separate machine on your network):

vboxmanage modifyvm "UbuntuServer" --nic1 bridged --bridgeadapter1 enp0s3

Replace enp0s3 with your host’s network interface name. Check available interfaces with ip link show.

Shared folders

Shared folders let you exchange files between the host and guest without network configuration. The guest needs Guest Additions installed (covered in the next step) for shared folders to mount automatically.

Add a shared folder to a VM:

vboxmanage sharedfolder add "UbuntuServer" --name "shared" --hostpath /home/user/shared --automount

Inside the guest, the shared folder mounts at /media/sf_shared. Your guest user needs to be in the vboxsf group to access it:

sudo usermod -aG vboxsf $USER

Log out and back in for the group change to apply.

Step 7: Install Guest Additions in the VM

Guest Additions improve VM performance and usability – you get better video resolution, seamless mouse integration, shared clipboard, and shared folder support. Install them inside the guest OS, not on the host. If you are running VMs for converting between VDI and other disk formats, Guest Additions are not required, but for interactive use they are essential.

First, install the required build dependencies inside the guest:

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

From the VirtualBox VM window menu, click Devices then Insert Guest Additions CD image. This mounts the Guest Additions ISO inside the VM. Then run the installer:

sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run

After the installer completes, reboot the guest for all changes to take effect:

sudo reboot

Verify Guest Additions are loaded after reboot:

lsmod | grep vbox

You should see modules like vboxguest, vboxsf, and vboxvideo loaded:

vboxsf                 90112  0
vboxguest             434176  2 vboxsf
vboxvideo              45056  0

Step 8: Troubleshoot Common VirtualBox Issues

Here are the issues you are most likely to hit on Ubuntu, Debian, and Kali Linux, and how to fix them.

Kernel module fails to load (vboxdrv)

If VirtualBox complains that the kernel module is not loaded, the most common cause is missing kernel headers or a failed DKMS build. Reinstall the headers and reconfigure VirtualBox:

sudo apt install linux-headers-$(uname -r) -y
sudo /sbin/vboxconfig

Check the output for errors. If the build succeeds, verify the module loads:

sudo modprobe vboxdrv
lsmod | grep vboxdrv

You should see vboxdrv listed in the output, confirming the module is active.

Secure Boot blocking kernel modules

On systems with UEFI Secure Boot enabled, unsigned kernel modules (like vboxdrv) are blocked by default. You have two options: sign the module or disable Secure Boot. If you use VirtualBox on Kali Linux, Secure Boot is commonly disabled already, but Ubuntu and Debian systems typically have it on.

Option A: Disable Secure Boot – Reboot, enter your UEFI/BIOS settings, and disable Secure Boot. This is the simpler option for development machines.

Option B: Sign the VirtualBox modules – Create a Machine Owner Key (MOK) and use it to sign the modules:

sudo mkdir -p /var/lib/shim-signed/mok
sudo openssl req -new -x509 -newkey rsa:2048 -keyout /var/lib/shim-signed/mok/MOK.priv -outform DER -out /var/lib/shim-signed/mok/MOK.der -nodes -days 36500 -subj "/CN=VirtualBox MOK/"
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der

Set a temporary password when prompted – you will need it on the next reboot. Reboot the machine, and the MOK Manager will appear. Select Enroll MOK, confirm with the password you set, then continue booting.

After enrollment, sign the VirtualBox modules:

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 /var/lib/shim-signed/mok/MOK.priv /var/lib/shim-signed/mok/MOK.der $(modinfo -n vboxdrv)

Load the module and verify:

sudo modprobe vboxdrv

VirtualBox conflicts with KVM

VirtualBox and KVM cannot run simultaneously because both need exclusive access to the hardware virtualization extensions. If KVM modules are loaded, VirtualBox VMs will fail to start or run extremely slowly.

Check if KVM modules are loaded:

lsmod | grep kvm

If you see kvm_intel or kvm_amd, unload them before running VirtualBox:

sudo modprobe -r kvm_intel
sudo modprobe -r kvm

To make this permanent, blacklist the KVM modules (only if you do not need KVM):

echo "blacklist kvm_intel" | sudo tee /etc/modprobe.d/blacklist-kvm.conf
echo "blacklist kvm_amd" | sudo tee -a /etc/modprobe.d/blacklist-kvm.conf
sudo update-initramfs -u

USB devices not visible in the VM

If USB devices are not showing up inside the VM, check two things: the Extension Pack must be installed (Step 3), and your user must be in the vboxusers group (Step 4). Also confirm the VM is configured for the right USB controller version under Settings then USB – select USB 2.0 or USB 3.0 depending on your device.

Manage VirtualBox VMs from the Command Line

VBoxManage is the full-featured CLI for VirtualBox. If you work with Vagrant for managing VirtualBox VMs, you will still find VBoxManage useful for troubleshooting. Here are the most common operations:

List all registered VMs:

vboxmanage list vms

List running VMs:

vboxmanage list runningvms

Start a VM in headless mode (no GUI window – ideal for servers):

vboxmanage startvm "VMName" --type headless

Gracefully shut down a VM (sends ACPI power button signal):

vboxmanage controlvm "VMName" acpipowerbutton

Force power off a VM (equivalent to pulling the power cord):

vboxmanage controlvm "VMName" poweroff

Take a snapshot before making changes:

vboxmanage snapshot "VMName" take "before-update" --description "Snapshot before OS update"

Conclusion

VirtualBox 7.2 is now installed and configured on your Ubuntu 24.04, Debian 13, or Kali Linux system. You have the Extension Pack for USB 3.0 and VRDP, Guest Additions for better VM integration, and the knowledge to troubleshoot the most common issues like kernel module failures and Secure Boot conflicts.

For production or performance-critical workloads, consider using hardware-level virtualization with KVM instead, or enable VirtualBox’s nested virtualization if you need to run hypervisors inside VMs. Keep VirtualBox updated regularly – Oracle releases security patches and bug fixes frequently.

Related Articles

Debian Install and Configure HAProxy on Debian 13/12 Networking BIND vs Dnsmasq vs PowerDNS vs Unbound [Benchmark] Databases How To Install LAMP Stack on Ubuntu 24.04 (Noble Numbat) Debian How to Install Adobe Flash Player on Kali Linux and Debian

Leave a Comment

Press ESC to close