Sunday, January 27, 2013

VirtualBox Errors on Ubuntu 12.10 64-bit Desktop Edition

Before you begin

The instructions below are to be followed at your own discretion and at your own risk. It is up to you to execute the commands outlined in this tutorial and is strongly advised that, if you do not understand the implications or repercussions of one or more of the following instructions, you do not proceed.

Now, let's get started:

If you installed the VirtualBox package from apt-get or via the Ubuntu Software Center and afterwards received the following message(s), then this tutorial is for you: VirtualBox - Error

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

'/etc/init.d/vboxdrv setup'

as root: If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary
VirtualBox - Error

Failed to open a session for the virtual machine <Your Virtual Machine Name>. The virtual machine '<Your Virtual Machine Name>' has terminated unexpectedly during startup with exit code 1.
At the time of this writing, when installing VirtualBox from the package manager on Ubuntu 12.10 64-bit Desktop Edition, the proper package doesn't get installed. In addition, if this is a fresh install of Ubuntu 12.10 64-bit Desktop Edition, you'll be missing some other packages essential for a working VirtualBox installation. To get VirtualBox up and running, do the following:
  • Read ahead and make sure that you are comfortable proceeding. If you want, make a back-up your machine, or, if you are using LVM (Logical Volume Management), take a snapshot of your current machine state.
  • Go to the Oracle VirtualBox downloads page and download the version of the VirtualBox Debian package for your Ubuntu installation into your /home/<your-username>/Downloads directory. Since this post is specifically targeting Ubuntu 12.10 64-bit ("Quantal Quetzal"), that's the version of the package that I downloaded.
  • Next, run the following commands from a terminal: cd ~/Downloads
    sudo apt-get update
    sudo apt-get purge virtualbox-*
    sudo apt-get install dpkg
    sudo apt-get install linux-headers-`uname -r`
    sudo apt-get install build-essential
    sudo dpkg -i virtualbox-*.deb
    sudo /etc/init.d/vboxdrv setup
    sudo usermod -aG vboxusers `whoami`
    The commands above will do the following:
    • Change your directory to /home/<your-username>/Downloads
    • Update your package list
    • Remove any existing VirtualBox installations
    • Makes sure that the Debian package management system is installed (If this is a fresh install of Ubuntu, it will be)
    • Install the linux-headers for the current Linux kernel version
    • Install the build tools for dpkg
    • Install the downloaded VirtualBox Debian package
    • Run the VirtualBox setup
    • Add the current logged-in user to the vboxusers group
  • Now log out and log back in or, if you want, reboot the machine.
That should do it. Now, launch your VirtualBox installation.