Posted by & filed under AWS/Linux/Unix/Devops stuff.

New to Virtualbox 3.2 OSE is a built in VNC server for accessing your Virtualbox VMs. This is a great feature, and I like this more than the VRDP feature available in the commercial Virtualbox since there is a wider variety of VNC clients that I’m aware of for Mac OS X in comparison to RDP clients.

However, I don’t believe this feature is compiled in by default just yet, and finding recent versions of Virtualbox OSE seems to be a  little tricky on some distros anyway, so I set out to compile this for myself with VNC server support on Ubuntu 10.04. The following is what I did to get it to compile and run properly…

New to Virtualbox 3.2 OSE is a built in VNC server for accessing your Virtualbox VMs. This is a great feature, and I like this more than the VRDP feature available in the commercial Virtualbox since there is a wider variety of VNC clients that I’m aware of for Mac OS X in comparison to RDP clients.

However, I don’t believe this feature is compiled in by default just yet, and finding recent versions of Virtualbox OSE seems to be a  little tricky on some distros anyway, so I set out to compile this for myself with VNC server support on Ubuntu 10.04. The following is what I did to get it to compile and run properly…

Compiling it was pretty much just a matter of following the instructions here. However, for me there were a few dependencies missing and some packages listed that are not available in Ubuntu 10.04 due to older versions being deprecated. You’ll also want to be sure that you have uninstalled all packages containing the word “virtualbox” offered via the Ubuntu repository (I forgot to install virtualbox-ose-dkms which resulted in error messages about mismatching module versions). The following is the final list of packages you’ll need to install prior to compilation:

apt-get install gcc g++ bcc iasl xsltproc uuid-dev zlib1g-dev libidl-dev libsdl1.2-dev libxcursor-dev libasound2-dev libstdc++6 libhal-dev libpulse-dev libxml2-dev libxslt1-dev python2.6-dev libqt4-dev qt4-dev-tools libcap-dev libxmu-dev mesa-common-dev libglu1-mesa-dev linux-kernel-headers libcurl4-openssl-dev ia32-libs libc6-dev-i386 lib32gcc1 gcc-multilib lib32stdc++6 g++-multilib libxinerama-dev libxrandr-dev libpam0g-dev libvncserver-dev

From there, I was able to:

  1. ./configure --disable-hardening (I haven’t tried the hardened compile yet)
  2. source ./env.sh
  3. kmk VBOX_WITH_VNC = 1

And to build the kernel modules:

  1. cd out/linux.x86/release/bin/src
  2. make
  3. sudo make install
  4. modprobe vboxdrv
  5. modprobe vboxnetflt
  6. modprobe vboxnetadp
  7. Give yourself r/w access to /dev/vboxdrv

You’ll find the VirtualBox binaries in out/linux.x86/release/bin.

  • John

    Thank you for the excellent post. Unfortunately, as of 9/2/2010, with Ubuntu 10.4 (amd64) fully up-to-date, compiling VirtualBox 3.2.8 fails.

    First, toward the end of the compile, it fails with “__stack_chk_fail”. Adding that symbol (perhaps dangerously) to src/VBox/Additions/x11/vboxvideo/undefined_68 allows the build to proceed (perhaps with unknown problems).

    Then, attempting to install the kernel modules fails with the useless message “Error: /usr/src/linux (version echo 2.6.32-24-server) does not match the current kernel (version 2.6.32-24-server).” Something emitted an “echo” into the version check. I fixed this by editing each of the three Makefiles in vboxdrv, vboxnetadp, and vboxnetflt and hard-coding the kernel version at the cited offending lines.

    I’ve not yet run the result, but it builds and installs. I’m afraid my simple fixing is hiding potential problems. YMMV.

  • http://www.netmusician.org joe

    Thanks for posting this, John.

    It seems to me like something in the newer versions of Virtualbox broke something, because these instructions were written for Ubuntu 10.04/amd64, just like your setup. I haven’t tried compiling Virtualbox in a while, but I’m very glad you posted this because I may upgrade soon!

    I do remember having the same problem with the kernel modules with testing a mainline kernel that also registered with the -server suffix. I take it you aren’t using the linux-generic package in the non-server Ubuntu version?

  • John

    Right, I don’t have linux-image-generic installed. I’ve got linux-image-2.6.32-24-server (and linux-image-server) installed, along with the linux-headers-2.6.32-24-server (and linux-headers-2.6.32-24 and linux-headers-server) installed.

  • John

    My changes must have worked, because I was able to remotely build and run a VM (itself running Lucid) with my compiled version of VirtualBox. I had some weird keyboard-encoding issues over the VNC console and was therefore unable to login to the newly-built VM, but fortunately I had enabled the ssh server. :-)

  • http://www.netmusician.org joe

    Those keyboard encoding issues can be a PITA! I can’t remember having those problems this time, but if you come up with a fix for those feel free to post them here!

    Perhaps you should suggest your compile fixes to the Virtualbox list, if you haven’t already done so? They seemed pretty receptive to working with me on coming up with this tutorial.