HOWTO: Install Linux Guest Additions + Xorg config

HOWTO: Install Linux Guest Additions + Xorg config

Postby Sasquatch » 21. Mar 2009, 18:22

This HowTo is Command Line based. It would be almost impossible to write a generic, graphical installation method because of all the different graphical environments (Gnome, KDE, Xfce, IceWM, FluxBox, etc.). All the commands here are run with root privileges. These privileges can be obtained by logging in as root (most distributions won't allow this on the GUI, or have root disabled) or use sudo at the beginning of the command. When you use a GUI, like Gnome, a terminal should be used (but you can also drop to a virtual terminal, or TTY, by using the Host key and F2). It can be usually found in the Accessories section of the panel menu. For Gnome, the menu is usually called Applications, but it depends on the distribution and environment (some use an image of a foot for the Gnome menu).
Skimming this howto and only execute the code blocks might not work if you don't exactly know what needs to be done or what you're doing. So take your time to read it all, so you understand what is happening, and more importantly, why it is needed.

System preparations
After you have installed your Linux Guest system, there are a few additional packages needed for the Guest Additions. These packages enables you to create kernel modules. For Debian and Debian based distro's like Ubuntu, you need the following packages:
    dkms
    build-essential
    linux-headers-generic (Ubuntu)
    linux-headers-{amd64 OR 686-pae OR 486} (Debian)
Code: Select all   Expand viewCollapse view
apt-get install dkms build-essential linux-headers-generic
Check the version you need with uname -r.

Mandriva users run the following:
Code: Select all   Expand viewCollapse view
urpmi dkms gcc make libgomp1 glibc-devel kernel-devel kernel-headers

Fedora users need the following packages:
    dkms
    binutils
    gcc
    make
    patch
    libgomp
    glibc-headers
    glibc-devel
    kernel-headers
    kernel-devel OR kernel-pae-devel
Code: Select all   Expand viewCollapse view
yum install dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel
Or alternatively:
Code: Select all   Expand viewCollapse view
yum install dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-pae-devel


SuSE users need the kernel-source and kernel-syms.

You have to make sure that the kernel-headers and/or kernel-source are of the same version as your running kernel. It's best to do a full system update and reboot before trying to install the Guest Additions. Additionally, installing DKMS before the GA is also recommended so you don't need to manually install the GA again after a kernel update. Note: Not all distributions have DKMS in their repo. Either continue without, or install them manually from source.
Note: If you run a different kernel flavour, you need to install the packages corresponding to that flavour. You can always find out which kernel you are running by issuing uname -r.

Mount the Guest Additions
Now that we have what is needed for the Guest Additions, it's time to actually start installing what we want. If you haven't done so already, mount the GA ISO to the VM. This is done using the Device Menu, then click on Install Guest Additions. See the screen shot.
Install-GA1.png
Select "Install Guest Additions..." from the menu
Install-GA1.png (23.02 KiB) Viewed 724500 times

Make sure that no other CD is already loaded for the VM, like the install disk. Unmount that one first. The CD doesn't always get mounted automatically, so you have to do that manually. Usually an icon appears on the Desktop with the name of the inserted CD. You can mount the disc from there, but if you don't have a GUI, you have to mount it using the command line. The CLI can also be used if you have a GUI. Use a terminal emulator for that.
In the CLI, check if there is a valid mount point for the CD. This is usually /media/cdrom, but any empty folder can be used as mount point. Now to mount the CD, issue the following command:
Code: Select all   Expand viewCollapse view
mount /dev/sr0 /media/cdrom

It's now mounted on /media/cdrom.

Install the GA
So, the CD is mounted. It should come up with a message about content that can be run from the CD on newer releases of the distro you use. This is usually a Desktop Manger or file manager setting, so not all Desktop Managers have this. Gnome, KDE and Xfce should have it, but I'm not sure if it's enabled by default. Accepting the autorun should install the GA now.

If there is no autorun message, or you don't trust it or want to do it manually, follow the steps below.
Go to the folder with a terminal (this can be easily done from a graphical file browser (like Nautilus (Gnome), Thunar (Xfce) or Dolphin (KDE)) by right-clicking on the folder and select "Open Terminal here", or use cd /path/to/cdrom). In that folder, check it's contents with the ls command, so you are certain you are at the right place and you know the file names. Depending on the architecture you run for the Guest (32 bit or 64 bit), you run one of the two commands:
Code: Select all   Expand viewCollapse view
sh ./VBoxLinuxAdditions-x86.run

Code: Select all   Expand viewCollapse view
sh ./VboxLinuxAdditions-amd64.run

Since 4.0, the Guest Additions are merged into one, architecture independent package, so it will be as follows:
Code: Select all   Expand viewCollapse view
sh ./VBoxLinuxAdditions.run

The Additions should install without issues. If there is an error, it usually states what's wrong. Check /var/log/vbox-install.log for more information. It's usually a version mismatch of the kernel headers or source. If you don't run Xserver, you will get a message about it that looks like this:
No Xserver found, skipping

This means that because you don't have X installed, the mouse and video modules won't be created and shared clipboard will not be available. If you install X later, you have to run the GA installer again.
There are some parameter options available for the GA installer. Run the installer with the parameter --help for a list of available parameters. See the manual too for some information about that.

Configuring your Xorg/Xserver
THIS IS ONLY NEEDED ON OLDER VERSIONS. ANY DISTRO AND/OR VB VERSION RELEASED IN 2010 OR LATER DOES NOT NEED THIS.

The GA are installed and you are asked to reboot the Guest. Do that, but don't be alarmed if your GUI doesn't start. It means that there is some misconfiguration in your xorg.conf file (/etc/X11/xorg.conf). Log in on the CLI (Command Line Interface) by hitting the Host Key + F2 (Host key is the key used to release the keyboard and used for shortcuts) and open xorg.conf with an editor as root. Nano is easier to use, but some prefer Vi or Vim. Check the file with this example configuration. This example is taken from an Ubuntu Guest. The syntax might be different for other distro's.
Code: Select all   Expand viewCollapse view
vim /etc/X11/xorg.conf

Code: Select all   Expand viewCollapse view
#Example xorg.conf from Ubuntu

Section "Device"
   Identifier   "Configured Video Device"
   Driver      "vboxvideo"
EndSection

Section "Monitor"
   Identifier   "Configured Monitor"
EndSection

Section "Screen"
   Identifier   "Default Screen"
   Monitor      "Configured Monitor"
   Device      "Configured Video Device"
EndSection

Section "InputDevice"
        Identifier  "vboxmouse"
        Driver          "vboxmouse"
        Option          "CorePointer"
        Option          "Device"        "/dev/input/mice"
EndSection

Section "ServerLayout"
        Identifier      "Default Layout"
        Screen          "Default Screen"        0 0
        InputDevice     "vboxmouse"
EndSection

As you see, there is no resolution provided to be used. Some distributions won't allow this and will prevent GDM/KDM to start. If you need a resolution, you have to add it to the screen section as a subsection. Please see the manpages for xorg.conf for an example, or your current xorg.conf configuration. Adding a resolution to the xorg.conf file will disable the dynamic resolution change function of the Guest Additions. This check was added in VB 2.1.4. If you use an older version of the GA, you will have the dynamic resolution despite the resolution noted in the xorg.conf file.
In case you DO need to specify a resolution (like Fedora 12), add something like this.
Code: Select all   Expand viewCollapse view
Section "Screen"
   Identifier   "Default Screen"
   Monitor      "Configured Monitor"
   Device      "Configured Video Device"
   DefaultDepth    24
   SubSection      "Display"
      Depth           24
      Modes           "1280x1024"
   EndSubSection
EndSection


Note, more recent versions of Xserver might not need this kind of configuration and everything is done automatically. The developers (from Xserver-Xorg) are planning to stop using xorg.conf for configuration and let HAL take over. A part of that is already working, but only with the open source drivers shipped with your xserver-xorg version. The VB video driver is not a default driver, just like the fglrx for ATi cards and nVidia-glx for nVidia cards. An explicit configuration to use the non-standard driver is needed for these kinds of drivers.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Return to Linux Guests

Who is online

Users browsing this forum: No registered users and 0 guests