Linux How to Install VirtualBox Linux Guest Additions

0 Comments

This post will describe how to install VirtualBox Guest Additions on your Linux guest operating system.

Sun’s VirtualBox is a general-purpose x86 machine virtualizer that runs on Windows, Linux/Unix, and OpenSolaris hosts. It supports a large number of guest operating systems, including Linux (kernel versions 2.4 and 2.6) and the usual Windows flavors. Guest Additions consist of drivers and kernel modules that improve the usability and performance of the guest operating system, including the ability to share the mouse pointer seamlessly between the guest and host systems without the need to free the pointer from the guest OS first; the ability to share the clipboard between the guest and host OS; and, better video support through the use of guest drivers for the X Window system that provide higher (and non-standard) video modes as well as accelerated video. VirtualBox and its Guest Additions addon are free software licensed under the GNU GPL.

The versions for the software discussed in this post were as follows:

  • Fedora v11 (Leonidas)
  • Ubuntu v9.04 (Jaunty)
  • VirtualBox v3.0.8
  • VirtualBox Guest Additions v3.0.6
  • Windows XP SP3
  • So, let’s get started.

    Download and mount

    VirtualBox Guest Additions are designed to be installed to the guest OS after it has been installed. So, if you haven’t already installed your Linux guest OS make sure you do that first. Also, and this is important, make sure you update the packages in your Linux guest OS before trying to install Guest Additions. Trust me, you’ll avoid a lot of problems if you do.

    The VirtualBox Guest Additions is provided as a single image ?le called VBoxGuestAdditions.iso. To install, you mount this image ?le as your guest OS’s CD/DVD-ROM drive and install it directly from the drive from within the guest OS.

    Start your guest OS and release your mouse pointer. Navigate up to the top of the window and select Devices->Install Guest Additions. The image should automatically mount as your guest OS’s CD/DVD-ROM drive. (you may see a disk icon of some sort on your guest OS desktop). Now, let’s install the Guest Additions. Open up a terminal and navigate to the directory where your CD/DVD-ROM is mounted (e.g., /media/cdrom0 or /media/VBOXADDITIONS_3.0.xxxxx). List the contents of the directory and you’ll notice several scripts. Find the one that applies to your particular Linux guest OS. So, for example, if your guest OS is 32-bit, you would use VBoxLinuxAdditions-x86.run. If it’s 64-bit, you would use VBoxLinuxAdditions-amd64. Now, run the script as root from this directory with the following command, substituting your script for the one in this example:

    ./ VBoxLinuxAdditions-x86.run
    

    The script will do a self-check to verify the integrity of the image, then it will proceed with uncompressing files, building new kernel modules, and installing drivers. After the script finishes, you should reboot your guest OS to ensure that Guest Additions is actually used.

    VirtualBox Guest Additions contain several different drivers. If for any reason you don’t want to install them all, you can specify the ones you want on the command line – for example ./VBoxLinuxAdditions-x86.run x11 will install the X Window drivers only. If you don’t specify any options, all components will be installed (recommended). Components already installed will be deactivated in order to prevent possible problems.
    The command ./VBoxLinuxAdditions-x86.run help will provide further information.

    Troubleshooting

    I’ve occasionally run into a couple of problems when installing Guest Additions. One is that Guest Additions doesn’t download or won’t automatically mount once it is downloaded. To solve this, simply download Guest Additions manually to a location on your host OS. Navigate up to the top of the guest OS window and select Devices->Mount CD/DVD-ROM-> CD/DVD-ROM Image and select Add. Navigate to where you downloaded the file to and select it. Once it’s been added to the list of images, highlight it by left-clicking on it and then choose Select. The image should now be mounted as your guest OS’s CD/DVD-ROM drive.

    The second problem I’ve encountered on my way to victory with Guest Additions is that the guest OS sometimes lacks the tools needed by Guest Additions to build the necessary kernel modules. You’ll receive messages like “…please install the build headers…” So, to fix this problem make sure to first update your packages. If that doesn’t fix the problem, then install the necessary build and kernel headers. For Ubuntu, and other debian-based distributions, run the following command as root:

    apt-get install linux-headers-$(uname -r)
    

    For Fedora-based systems, run the following command as root:

    yum install gcc
    yum install kernel-devel-$(uname –r)
    

    The uname -r in the above command passes your kernel version to variable $ and appends it to linux-headers.

    Conclusion

    I’m starting to use VirtualBox a lot now to help test and evaluate various Linux distributions in a more flexible way. With the exception of a few minor installation issues, Guest Additions is easy to set up and makes working in your guest OS a much better experience.

    Tags: , , ,

    Leave a Reply