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.
This part is quite easy. We just need to add a new apt source, import the related pgp key, and install the package.
deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian bullseye non-free contrib
(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
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.
(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.
# 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