Installing VirtualBox inside of OpenVZ - missing sources
Solution 1
In OpenVZ, you do not have any control over the kernel. This is because OpenVZ does not virtualize hardware, and is a "container", rather than a virtual machine on the host node. Since you will be unable to load modules into the host's kernel, this will not be possible.
Solution 2
Solution to running VirtualBox inside OpenVZ (in an OpenVZ container) is simple. This procedure has been tested on ProxMox VE 2.2
- Assuming you have control over the OpenVZ host (using your private Proxmox installation, for example)
- Install VirtualBox from backports on the OpenVZ host machine, version 4.0.10 (kernel modules will be built automatically):
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> /etc/apt/sources.list
apt-get install virtualbox
- In /etc/default/virtualbox =>
LOAD_VBOXDRV_MODULE=1
- Attach virtualbox device nodes to the container that you wish to run virtualbox in:
vzctl set <VEID> --devnodes vboxdrv:rw --devnodes vboxnetctl:rw --save
- Install VirtualBox from backports inside the container in the same way as point #1 above.
- Run VirtualBox inside the container. NAT networking works, Port forwarding works, Host-Only networking fails to work.
Related videos on Youtube
Comments
-
Peng over 1 year
I'm attempting to install VirtualBox inside of an offsite OpenVZ instance I got a good deal on. The point being to run a small Windows XP box for some kind of Windows Server.
- Yes, it's an experiment.
- No, it's not for production.
It seems like everything would work fine, but the installer can't find my distro's sources. My instance has Debian 6 installed. Running
uname -r
gives me2.6.32-042stab061.2
. I've looked all through my apt-cache for anything similar, tried installing linux-sources-2.6.32 and a variety of linux-headers, but I'm having no luck.Does anyone know how I can get the proper sources for this instance so VirtualBox can compile itself? Thanks.
-
jordanm over 11 yearsOpenvz is not a real virtual machine. You run off the host's kernel and not your own. You can not load kernel modules into your kernel from within a container. That kernel looks like the RHEL/Centos 6 kernel provided by Openvz.
-
Peng over 11 yearsDoes that mean that this is an impossible goal? What if the container was also running CentOS 6 - would that be a match enough to get it running?
-
jordanm over 11 yearsYes, it's an impossible goal from within a container. If you can't load kernel modules, you can't run virtualbox.
-
Peng over 11 yearsThanks. If you want to add that as an answer I'll give you the credit for it.
-
Peng over 11 yearsThanks for the information! Unfortunately in this case I don't have any control over the OpenVZ host, just the instance :(
-
Léo Lam almost 10 yearsSometimes, installing VirtualBox will also install a kernel inside the container. This will obviously not work and will leave dpkg in a broken state -- you will have to manually remove the kernel for it to work properly again.