All Articles

Setting up VirtualBox in Debian 11 Bullseye

vbox-bullseye

Oracle VM VirtualBox is a type-2 hypervisor for x86 virtualization developed by Oracle Corporation. To install it to Debian 11 Bullseye, there’re a few steps.

Install the debian package

This part is quite easy. We just need to add a new apt source, import the related pgp key, and install the package.

  • add following line to a new file under /etc/apt/sources.list.d.
deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bullseye non-free contrib
  • import the key and run apt commands
(root)# wget -q -O - http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc | apt-key add -
(root)# apt update --fix-missing
(root)# apt install virtualbox
  • (optional) you may download the extension pack from oracle.

(Optional) UEFI Secure Boot

If you see some error message like,

If your system is using EFI Secure Boot you may need to sign the kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load them. Please see your Linux system's documentation for more information.

you have to sign your kernel module.

  • first, you need to generate and import your MOK(Machine Owner Key).
(root)# apt install mokutil openssl
(root)# openssl req -new -x509 -newkey rsa:2048 -keyout vbox.key -outform DER -out vbox.der -subj "/CN=Virtual Box/"
(root)# mokutil --import vbox.der

after doing this, please reboot your machine to make sure the import operation is executed.

  • then please sign the modules, follow the instructions from debian.
# environment variables
(root)# VERSION="$(uname -r)"
(root)# SHORT_VERSION="$(uname -r | cut -d . -f 1-2)"
(root)# MODULES_DIR=/lib/modules/$VERSION
(root)# KBUILD_DIR=/usr/lib/linux-kbuild-$SHORT_VERSION
# sign modules, one by one (sign multiple modules is not supported)
(root)# "$KBUILD_DIR"/scripts/sign-file sha256 /path-to/vbox.key /path-to/vbox.der vboxdrv.ko
(root)# "$KBUILD_DIR"/scripts/sign-file sha256 /path-to/vbox.key /path-to/vbox.der vboxnetadp.ko
(root)# "$KBUILD_DIR"/scripts/sign-file sha256 /path-to/vbox.key /path-to/vbox.der vboxnetflt.ko
# don't forget to reimport signed modules
(root)# modprobe vboxdrv
(root)# modprobe vboxnetadp
(root)# modprobe vboxnetflt

Published Aug 13, 2022

Flying code monkey