Search

VirtualBox: A virtual PC for you

December 5th, 2007 edited by Tincho

Article submitted by Tomas Pospisek. Please help DPOTD by submitting good articles about software you like!

VirtualBox is a piece of software that uses virtualisation to simulate a PC. With it you can run Windows, Open BSD or even Linux from your Debian system. Since it also runs on Windows and Mac OS, you can use it to run Debian from that other non-free OS. Note however that it only works on x86 and x86_64 hosts.

You can use it if you want to test or have a look at a live CD distribution or to help the KDE project test the new KDE4 without messing up your current desktop.

You can do all this in a nice and hassle free GUI, driven by menus or application wizards. Here you can see the mentioned "KDE Four Live" CD booted up and ready within VirtualBox.

virtualbox-ose screenshot

VirtualBox requires to load its own set of kernel modules and won’t start without them. There is a package providing pre-built modules for the stock kernels in testing, you will need to manually install the correct version for your kernel. If those packages doesn’t suit you, you will need to compile them; the standard Debian way to do this would be:

$ sudo apt-get install virtualbox-ose virtualbox-ose-sources module-assistant
$ sudo module-assistant prepare virtualbox-ose
$ sudo module-assistant auto-install virtualbox-ose
$ ls /usr/src/virtualbox-ose-modules-*
$ sudo dpkg -i /usr/src/virtualbox-ose-modules-*.deb

That last line will need to be re-written to pick the virtualbox-ose-modules package that corresponds to your kernel.

You’ll also need to add the users that should be allowed to run VirtualBox to the vboxusers group. I’m adding the current user here:

$ sudo adduser `whoami` vboxusers

Now you have to re-login so that your process context picks up the fact that you now belong to then vboxusers group. You can do that by "su"ing into yourself:

$ su `whoami` -

And here you go:

$ virtualbox

Note for those who like to know how it works: VirtualBox tries to run native code whenever possible, when it’s necessary it uses dynamic recompilation as QEMU does. It also moves guest code intended to run on ring 0 to ring 1, and because of this it doesn’t use the VMX features from the processor too much. See the technical documentation for details.

The virtualbox-ose package is available in Debian testing and unstable, and in Ubuntu since Gutsy (if you’re thinking of upgrading to testing, be sure you are aware of the implications, before doing so!). There’s also a backport to the currently stable Debian "etch" release.

Posted in Debian, Ubuntu |

10 Responses

  1. Tim Says:

    > su `whoami` -

    Eeeek! So convoluted and insecure. Save a fork(), use newgrp(1).

  2. Joachim “nomeata” Breitner Says:

    When I recently tried to install the package and started the GUI, it asked me to register. What is the reason for this quite un-debian-like behaviour − can you comment on that?

  3. lavaeolus Says:

    You can ignore the registration, it will work without and will never appear again, virtual-box is a third-party application from innotek, it’s not a debian-only package.

    btw. it is available for most recent distributions, on the innotek site you can download packages for different systems, some distributions (mandriva, fedora, openSUSE, possibly others) have customized packages in their repositories

  4. voislav Says:

    I have been running Windows 2000 in VirtualBox on Mandriva 2008 for a couple of weeks now and it’s pretty good. Guest OS is very responsive, not much difference than installing it directly and there have been no crashes. It’s a good, polished piece of software.

  5. Norman Says:

    I’ve been using virtualbox for about a month now, and my experiences have proven to me that it’s head & shoulders above vmware. The only thing that I don’t like with virtualbox is that it doesn’t have bridging ready to go as part of the package in Linux or Windows. But, little overhead (as opposed to vmware’s hefty overhead), and working with everything I throw it it (unlike vmware’s and xen’s abyssmal success rate with my more recent setups) makes virtualbox the only viable solution for me.

  6. jimcooncat Says:

    Using it to run XP on my Ubuntu, I haven’t felt any urge to set up a network bridge. The default NAT setup let me easily poke a hole with a few long command lines modified from the Users Manual.

    I did this in order to run UltraVNC server on the XP virtual machine so I could use it from a thin client. Worked like a charm — once I remembered to open the port up also in the WinFirewall!

  7. Mike Says:

    Using etch and etch-backports, I had to follow a slightly different procedure:

    1) On Debian, sudo is not used by default, so you just become root by typing ’su’.

    2) After running ‘module-assistant auto-install virtualbox-ose’ (although you can, and I did, just run ‘m-a a-i virtualbox-ose’), there’s no need to manually install the generated package - m-a does that for you i.e. the following two commands were unneeded.

    3) The command ‘modprobe vboxdrv’ needed to be run as root so that the module is available.

  8. tpo Says:

    Tim wrote:

    > > su `whoami` -
    > Eeeek! So convoluted and insecure. Save a fork(), use newgrp(1).

    Cool, didn’t know that one! Thanks, Tim!

  9. vevhlos Says:

    great how-to,
    before reading this i had problems with the module (vboxdrv)
    thanks a lot!

  10. yaxel84 Says:

    Great How-to, however, when I restart the system or change other day, again the same error appear. (Cuando la apago por un par de horas y quiero volver a usar el virtualbox, me vuelve a salir el mismo error). and every day I have to compile the virtualbox-ose-modules. I have an amd64 machine… sorry, but my english is too bad… Thanks