Installing VirtualBox on Kali (Host)

Table of Contents

You can install VirtualBox on Kali Linux, allowing you to use virtual machines (VMs) inside of Kali Linux. However if you are wanting to install Kali Linux as a VM, you want our Kali Linux Guest VirtualBox guide.

VMs are great. There are many upsides with using them. One of the being, able to run multiple Operating Systems (OSs) at the same time. You can have your host machine “untouched”, and then only interact with the guest VMs. Another is when something is going right, take a snapshot. When something goes wrong, revert back.

VirtualBox is free and open source. There are a few other software such as QEMU, KVM/Xen with virt-manager. Then there is also VMware Workstation & Fusion, which is a commercial software (there is VMware Player which is free but it is limited in features).

VirtualBox is officially available in kali-rolling repositories.

There are two ways to install virtualbox: 1.From Kali repositories. 2.From Oracle repository.

Preparation

Before trying to install VirtualBox, please make sure your version of Kali Linux is up-to-date, our apt sources are properly set and if required, reboot the machine:

kali@kali:~$ sudo apt update
[...]
kali@kali:~$
kali@kali:~$ sudo apt full-upgrade -y
[...]
kali@kali:~$
kali@kali:~$ [ -f /var/run/reboot-required ] && sudo reboot -f
kali@kali:~$

1. From Kali Linux repositories

Install virtualbox and linux-headers-generic:

kali@kali:~$ sudo apt update
[...]
kali@kali:~$
kali@kali:~$ sudo apt install virtualbox linux-headers-generic
[...]
kali@kali:~$

The extension pack can be installed through:

kali@kali:~$ sudo apt install virtualbox-ext-pack
[...]
kali@kali:~$

2. From Oracle Virtualbox third-party repository

Download

The first thing we are going to do is import VirtualBox’s repository key:

kali@kali:~$ curl -fsSL https://www.virtualbox.org/download/oracle_vbox_2016.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/oracle_vbox_2016.gpg
[...]
kali@kali:~$ curl -fsSL https://www.virtualbox.org/download/oracle_vbox.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/oracle_vbox.gpg
[...]
kali@kali:~$

We then move onto adding VirtualBox’s repository. We add this to a separate file, so it does not interfere with Kali Linux’s main repository. We also will be making sure to state where the keyring is at so the files can be properly signed. Our CPU architecture is amd64. You may need to alter the example below if yours is different.

One thing to bear in mind, Kali Linux is based on Debian, so we need to use Debian’s current stable version (even though Kali Linux is a rolling distribution). At the time of writing, its “bullseye”:

kali@kali:~$ echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian bullseye contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
kali@kali:~$

As we have altered our network repository, we need to re-build the cache:

kali@kali:~$ sudo apt update
[...]
kali@kali:~$

As VirtualBox has various kernel modules (e.g. vboxdrv, vboxnetflt and vboxnetadp), we need to make sure they are kept up-to-date when Kali Linux’s kernel gets updated. This can be achieved using dkms:

kali@kali:~$ sudo apt install -y dkms
[...]
kali@kali:~$

Setup

Now its time to install VirtualBox itself (along with its Extension Pack to expand VirtualBox’s advanced features) and the Linux headers necessary:

kali@kali:~$ sudo apt install -y virtualbox virtualbox-ext-pack linux-headers-generic
[...]
kali@kali:~$

When prompted, read and accept the license.

You can now find VirtualBox in the menu or start it via the command line:

kali@kali:~$ virtualbox
kali@kali:~$

If you now wish, you are able to install Kali Linux in a VirtualBox VM (on Kali Linux).


Updated on: 2024-Oct-01
Authors: g0tmi1k , Rclev4Sec