Installing VirtualBox inside of OpenVZ - missing sources

6,035

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

  1. Assuming you have control over the OpenVZ host (using your private Proxmox installation, for example)
  2. Install VirtualBox from backports on the OpenVZ host machine, version 4.0.10 (kernel modules will be built automatically):
  3. Attach virtualbox device nodes to the container that you wish to run virtualbox in:
    • vzctl set <VEID> --devnodes vboxdrv:rw --devnodes vboxnetctl:rw --save
  4. Install VirtualBox from backports inside the container in the same way as point #1 above.
  5. Run VirtualBox inside the container. NAT networking works, Port forwarding works, Host-Only networking fails to work.
Share:
6,035

Related videos on Youtube

Peng
Author by

Peng

Ones and zeros. #SOreadytohelp

Updated on September 18, 2022

Comments

  • Peng
    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 me 2.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
      jordanm over 11 years
      Openvz 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
      Peng over 11 years
      Does 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
      jordanm over 11 years
      Yes, it's an impossible goal from within a container. If you can't load kernel modules, you can't run virtualbox.
    • Peng
      Peng over 11 years
      Thanks. If you want to add that as an answer I'll give you the credit for it.
  • Peng
    Peng over 11 years
    Thanks for the information! Unfortunately in this case I don't have any control over the OpenVZ host, just the instance :(
  • Léo Lam
    Léo Lam almost 10 years
    Sometimes, 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.