Cant install VirtualBox in a Lxd container

I’m trying to install VirtualBox in a lxd container (not vm) running 22.04. My container has a gnome desktop which I can Vnc into fine. My plan is to migrate a number of old windows vm I currently have under an old dedicated 18.04 machine.

The deb file is virtualbox-6.1_6.1.36-152435~Ubuntu~jammy_amd64.deb from

This is what I get…

root@container:~# /sbin/vboxconfig Stopping VirtualBox services.
depmod: WARNING: could not open modules.order at /lib/modules/5.15.0-39-generic: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/5.15.0-39-generic: No such file or directory Starting VirtualBox services. Building VirtualBox kernel modules.
depmod: WARNING: could not open modules.order at /lib/modules/5.15.0-39-generic: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/5.15.0-39-generic: No such file or directory failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.

There were problems setting up VirtualBox.  To re-start the set-up process, run
as root.  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.
root@container:~# cat /etc/*release
PRETTY_NAME="Ubuntu 22.04 LTS"
VERSION="22.04 LTS (Jammy Jellyfish)"

I can’t look at dmesg (which I assume is normal) and there’s nothing else useful in /var/log/*
The two files modules.order + .builtin exist on the host machine (also Ubuntu 22.04) so not sure why are not in the container (should I just copy them there?).

Containers share the host’s kernel. As such unprivileged containers are not allowed to install new kernel modules as they would affect the host’s operation as well.

What are you trying to achieve by using VirtualBox inside a container?

This is how I got it working…
I used the -vm switch on lxc launch to create a virtual machine instead of a container. Next I installed xfce desktop and tightvnc.

Before installing virtualbox I had to turn off secure boot or virtualbox (modprobe vboxdrv) will not install correctly as it’s not signed. The advantage of a virtual-machine rather than a container (ie. the -vm switch) is that you can see dmesg to find out why something failed.

To turn off secure boot I did this…

lxc profile copy default no-secure-boot
lxc profile set no-secure-boot security.secureboot=false
lxc profile apply <CONTAINER> no-secure-boot

Then, in the container, you can check the state of secure boot like this…
sudo mokutil --sb-state

And then install virtualbox like this…
sudo apt-get install virtualbox

Once virtualbox is installed you can switch the profile on your container back to boot securely
I’m not sure if this could have been done without the step of using a container rather then a virtual-machine, I guess one day I might try it.


I have a bunch of legacy systems, each in it’s own environment inside a VirtualBox setup, all on an old unit that needs to go. If I can export them off the old unit and install into a VirtualBox inside an lxd that gives me an easy route.
I have got this working now, but thanks for your help.