logo

Home page
Articles for Windows, Linux, OS X
Mac tips and articles
Mac tips
Windows 8 tips and articles
Windows 7 tips and articles
Vista Tips
XP Tips
Linux tips and articles
Read the blog
Online store
Windows, Linux, OS X programs
Links
About

Linux hints and tips

Install VirtualBox additions

VirtualBox is a free open source virtualisation program that enables you to run an operating system within a window on the desktop. It's very useful for testing different versions of Linux without having to actually install them on the computer. You can run Linux within Windows, Mac OS X, and even another Linux distro within a window on your Linux desktop.

It was originally developed by Innotek GmbH, then Sun, and now Oracle. You can find Oracle VM VirtualBox at the corporate website. If you follow the links to the download page you'll see links to get VirtualBox and VirtualBox Open Source Edition.

Assuming you've got VirtualBox and have installed Linux in it, you'll want to install the VirtualBox additions. One thing these do is to enable the mouse to pass from the guest operating system, such as Linux running in a window, to the host operating system, the one that's installed on your computer. Without the VirtualBox extensions the mouse is trapped inside the guest OS window and you have to press a hotkey (right Control on PCs, left Apple key on Macs), to switch to the host OS.

Another thing the VirtualBox additions do is to enable you to resize the guest OS window. You can drag the corners or sides like a regular window to change the guest OS desktop size. You can also switch to full screen mode (use the menu or press the hotkey and F). You'll then be using the guest OS, any Linux distro you like, for exmaple, as if it was the real thing installed on your computer.

You can also access a shared folder on the host OS from within the guest OS and this is useful for passing files from one to the other.

Installing the VirtualBox additions is easy with some Linux distros, but not all of them and you could run into problems. Ubuntu is a piece of cake, and distros based on Ubuntu are generally easy too. Here's what you do:

  • Start the guest OS - Linux - in VirtualBox
  • Click Install Guest Additions on the VirtualBox menu in the guest OS window
  • Open a Terminal window in the guest OS
  • Enter: sudo apt-get install dkms
  • Enter: cd /cdrom
  • Enter sudo sh ./VBoxLinuxAdditions-x86.run
  • After it's finished, close the Terminal window and restart

Solve VirtualBox additions installation problems

For various reasons, the instructions above don't always work, but there are usually solutions to the problem. For example, instead of typing sudo, you might need to enter su on its own and then the root password. Then just type apt-get install dkms. If that doesn't work then run Add-Remove Programs or the Synaptic Package Manager or whatever the program is called that enables you to install software. Search for dkms and install it.

You may find that cd /cdrom doesn't work. VirtualBox additions is loaded as a virtual CD and it should appear on the desktop or in the Computer window if you open the file browser. You might need to type something like cd /media and then cd VBOXADDITIONS_3.0.2_49928 or whatever the CD is called (type ls to get a directory listing in the Terminal window to see what's there). After navigating to the CD you can enter the sudo... command line above or type su on it's own (if you haven't already) and enter the password.

If you manage to locate the VirtualBox additions CD that's mounted and run the file, sometimes you'll get an error message about a missing GNU C compiler. Some Linux distros include the compiler by default, but some don't and if it's not installed you'll have to install it. Run Add-Remove Programs or the Synaptic Package Manager or whatever the program is called that enables you to install software and find the GNC C compiler (a search for gcc might do the trick). Fedora calls them Various Compilers (C, C++, Objective C, Java...). Select it and also select C++ support for GCC if it's listed too. You can then return to the Terminal window and try the sh ./VBoxLinuxAdditions-x86.run command again.

This sometimes still fails with a message that you need to install the build and header files for your current Linux kernal. OK, back to the Add-Remove Programs or the Synaptic Package Manager and search for headers. Specifically, ones for Linux rather than special ones for specific software packages. They may be called something like libc6-dev (GNU C Library: Development Libraries and Header Files), Linux-headers-generic (GNU C Library: Development Libraries and Header Files), Linux-headers-2.6.28 (Header files related to Linux kernel version 2.6.28). Install them and then try the sh ./VBoxLinuxAdditions-x86.run command again.

There are many Linux distros and some are quite similar, but others aren't. Hopefully, there is enough info here to get the VirtualBox extensions installed. However, sometimes no amount of fiddling with the commands and installed files will get them running and you could never guess how to do it. After some searching on the web, this is what you need to do to get VirtualBox additions working in Debian:

  • Login as root
  • Update your APT database with apt-get update
  • Install the latest security updates with apt-get upgrade
  • Install required packages with apt-get install build-essential module-assistant
  • Configure your system for building kernel modules by running m-a prepare
  • Click on Install Guest Additions from the Devices menu, then run mount /media/cdrom
  • Run sh /media/cdrom/VBoxLinuxAdditions.run, and follow the instructions on screen

Go to Linux tips index...

VirtualBox additions in Mandriva 2010 Linux

copyright