Skip to content

Installing Latest VirtualBox (7.0)

Remove Current Installation

Remove the current virtualbox (6.x) packages when installed at all.

apt remove ---purge virtualbox

Solution with a Sources-file

Add a source-list file virtualbox.sources to the directory /etc/apt/sources.list.d/.

cat <<EOD | sudo tee /etc/apt/sources.list.d/virtualbox.sources >/dev/null
Types: deb
Architectures: $(dpkg --print-architecture)
Suites: stable
URIs: https://download.virtualbox.org/virtualbox/debian
Suites: $(lsb_release -cs)
Components: contrib
Signed-By:
$(wget -qO- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sed 's/^/ /')
EOD

Install using List-file

Add Repository Keys

Since apt-key add using the /etc/apt/trusted.gpg file is deprecated use the following method using /etc/apt/trusted.gpg.d directory.

wget -q -O - "https://www.virtualbox.org/download/oracle_vbox_2016.asc" | gpg --yes --dearmor -o /etc/apt/trusted.gpg.d/oracle_vbox_2016.gpg
wget -q -O - "https://www.virtualbox.org/download/oracle_vbox.asc" | gpg --yes --dearmor -o /etc/apt/trusted.gpg.d/oracle_vbox.gpg

Check if the keys were added using apt-key list | grep oracle_vbox and 2 must occur.

Add Source List

apt-add-repository --yes "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib"

To remove the apt-repository just add the option --remove.

Install the Package

Update and install the virtualbox packages.

apt update # Not actually needed since apt-add-repository does it by default. 
apt install virtualbox-7.0 virtualbox-ext-pack

When using Ubuntu 22.04

When package linux-image-generic-hwe-22.04 is installed the header files are missing for the current kernel and result in an error NS_ERROR_FAILURE 0X80004005. To fix this run the next command:

apt install "linux-headers-$(uname -r)" virtualbox-7.0 virtualbox-dkms dkms && modprobe vboxdrv

Install the Guest Additions ISO

apt install virtualbox-guest-additions-iso

Add User to the Group

To be able to use VirtualBox without a warning message about not able to list USB devices add the user to the vboxusers group.

usermod -a -G vboxusers 'username'