VirtualBox is a free, open-source virtualization application developed by Oracle that lets you run a complete operating system inside a window on your existing Debian 12 system. Each virtual machine runs independently, using a dedicated slice of your CPU, RAM, and disk space, while leaving the host system untouched. This makes it ideal for testing distributions, running isolated development environments, or trying software you would not want installed directly on your main system.

This guide walks through installing VirtualBox on Debian 12 from the official Oracle repository, adding the Extension Pack for USB and remote desktop support, and creating your first virtual machine. Before running any commands, make sure your user account has sudo privileges on Debian 12.

Quick Answer

Run these four commands in sequence to install VirtualBox 7.0 on Debian 12:

sudo apt install curl wget gnupg2 lsb-release -y
curl -fsSL https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/vbox.gpg
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update && sudo apt install virtualbox-7.0 -y

Launch VirtualBox from the Activities menu after installation completes.

How to Install VirtualBox on Debian 12

Step 1: Install the curl Utility

The curl command downloads data from a server using the terminal. Install it alongside wget and gnupg2, which are needed to fetch and verify the VirtualBox repository signature:

sudo apt install curl wget gnupg2 lsb-release -y
Terminal output showing sudo apt install curl wget gnupg2 lsb-release completing on Debian 12

Step 2: Download the VirtualBox GPG Key

Download the official VirtualBox GPG key and save it to the trusted keys directory. This lets apt verify that packages from the VirtualBox repository are genuine:

curl -fsSL https://www.virtualbox.org/download/oracle_vbox_2016.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/vbox.gpg
Terminal showing curl command saving the VirtualBox GPG key to /etc/apt/trusted.gpg.d/vbox.gpg on Debian 12

Step 3: Add the VirtualBox Repository and Update

Add the official VirtualBox repository to /etc/apt/sources.list.d so apt can find and download VirtualBox packages:

echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
Terminal output showing the VirtualBox repository entry added to /etc/apt/sources.list.d/virtualbox.list

Update the package lists to include the new repository:

sudo apt update
Terminal output of sudo apt update fetching package lists from the VirtualBox repository on Debian 12

Step 4: Install the Required Kernel Headers

VirtualBox requires kernel headers and DKMS to build its kernel modules. DKMS automatically rebuilds those modules whenever your kernel is updated, so VirtualBox keeps working after system upgrades:

sudo apt install linux-headers-$(uname -r) dkms -y
Terminal output showing sudo apt install linux-headers and dkms completing successfully on Debian 12

Step 5: Install VirtualBox

Install VirtualBox 7.0 from the Oracle repository you added:

sudo apt install virtualbox-7.0 -y
Terminal output showing sudo apt install virtualbox-7.0 completing the VirtualBox installation on Debian 12

Verify the installation by checking the installed version:

vboxmanage -v | cut -dr -f1
Terminal showing vboxmanage -v output confirming the VirtualBox version installed on Debian 12

Step 6: Add Your User to the vboxusers Group (Optional)

To pass USB devices through to guest virtual machines, add your user account to the vboxusers group. Replace user with your actual username:

sudo usermod -aG vboxusers user
Terminal showing sudo usermod -aG vboxusers command adding a user to the vboxusers group on Debian 12

Activate the new group membership in the current shell without logging out:

newgrp vboxusers
Terminal showing newgrp vboxusers command activating the vboxusers group membership in the current session

Step 7: Install the VirtualBox Extension Pack (Optional)

The VirtualBox Extension Pack adds USB 2.0/3.0 support, webcam pass-through, VirtualBox Remote Desktop Protocol (VRDP), and disk image encryption. Download it with wget:

wget https://download.virtualbox.org/virtualbox/7.0.14/Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack
Terminal showing wget downloading the Oracle VM VirtualBox Extension Pack file on Debian 12

Install the downloaded Extension Pack:

sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.14.vbox-extpack
Terminal showing sudo vboxmanage extpack install command installing the VirtualBox Extension Pack on Debian 12

When prompted to accept the license terms, enter y to continue:

Terminal prompt asking the user to accept the VirtualBox Extension Pack license agreement by entering y

Confirm the Extension Pack is installed correctly:

vboxmanage list extpacks
Terminal output of vboxmanage list extpacks confirming the VirtualBox Extension Pack is installed and active

How to Use VirtualBox on Debian 12

With VirtualBox installed, here is how to create and start your first virtual machine:

Step 1: Create a New Virtual Machine

Launch VirtualBox from the Activities menu. Click Machine then New, or press Ctrl + N, to open the new VM wizard:

VirtualBox Manager window showing the Machine menu open with the New option to create a virtual machine

Step 2: Specify Virtual Machine Details

Enter a Name for your VM, choose the Folder where VirtualBox will store its data, and select the ISO Image of the operating system you want to install. Uncheck Skip Unattended Installation to let VirtualBox handle the OS setup automatically using the credentials you provide in the next step:

VirtualBox New Virtual Machine wizard showing the Name, Folder, and ISO Image fields with Skip Unattended Installation checkbox

Step 3: Add User Details

On the Unattended Guest OS Install Setup screen, enter the Username and Password for the guest OS. You can also set a custom Hostname and Domain Name for the virtual machine:

VirtualBox Unattended Guest OS Install Setup screen showing Username, Password, Hostname, and Domain Name input fields

Step 4: Allocate System Resources

Set how much RAM and how many CPU cores the virtual machine can use. A minimum of 2 GB RAM and 2 CPU cores works for most lightweight guest operating systems:

VirtualBox Hardware configuration screen showing RAM amount and CPU count sliders for the new virtual machine

On the next screen, set the virtual hard disk size. Most guest operating systems need at least 20 GB of disk space:

VirtualBox Virtual Hard Disk configuration screen showing disk size allocation slider for the new virtual machine

Review the summary and click Finish to create the virtual machine:

VirtualBox Summary screen showing all virtual machine configuration settings before clicking Finish to confirm

Step 5: Start the Virtual Machine

Select the VM from the left pane of Oracle VM VirtualBox Manager and click Start. VirtualBox launches the guest OS installation automatically using the ISO image you selected. Follow the on-screen prompts to complete the installation:

VirtualBox Manager showing the Start button highlighted to begin launching and installing the virtual operating system

How to Remove VirtualBox from Debian 12

To uninstall VirtualBox completely, run:

sudo apt remove --purge virtualbox

To also delete all virtual machines and their configuration files, run these two commands:

sudo rm ~/"VirtualBox VMs" -Rf
sudo rm ~/.config/VirtualBox/ -Rf

Related Guides