Chapter 4. Guest Additions

Table of Contents

Introduction
Installing and Maintaining Guest Additions
Guest Additions for Windows
Guest Additions for Linux
Guest Additions for Solaris
Guest Additions for OS/2
Shared folders
Manual mounting
Automatic mounting
Hardware-accelerated graphics
Hardware 3D acceleration (OpenGL and Direct3D 8/9)
Hardware 2D video acceleration for Windows guests
Seamless windows
Guest properties
Guest control
Memory overcommitment
Memory ballooning
Page Fusion

The previous chapter covered getting started with VirtualBox and installing operating systems in a virtual machine. For any serious and interactive use, the VirtualBox Guest Additions will make your life much easier by providing closer integration between host and guest and improving the interactive performance of guest systems. This chapter describes the Guest Additions in detail.

Introduction

As mentioned in the section called “Some terminology”, the Guest Additions are designed to be installed inside a virtual machine after the guest operating system has been installed. They consist of device drivers and system applications that optimize the guest operating system for better performance and usability. Please see the section called “Supported guest operating systems” for details on what guest operating systems are fully supported with Guest Additions by VirtualBox.

The VirtualBox Guest Additions for all supported guest operating systems are provided as a single CD-ROM image file which is called VBoxGuestAdditions.iso. This image file is located in the installation directory of VirtualBox. To install the Guest Additions for a particular VM, you mount this ISO file in your VM as a virtual CD-ROM and install from there.

The Guest Additions offer the following features:

Mouse pointer integration

To overcome the limitations for mouse support that were described in the section called “Capturing and releasing keyboard and mouse”, this provides you with seamless mouse support. You will only have one mouse pointer and pressing the Host key is no longer required to "free" the mouse from being captured by the guest OS. To make this work, a special mouse driver is installed in the guest that communicates with the "real" mouse driver on your host and moves the guest mouse pointer accordingly.

Shared folders

These provide an easy way to exchange files between the host and the guest. Much like ordinary Windows network shares, you can tell VirtualBox to treat a certain host directory as a shared folder, and VirtualBox will make it available to the guest operating system as a network share, irrespective of whether guest actually has a network. For details, please refer to the section called “Shared folders”.

Better video support

While the virtual graphics card which VirtualBox emulates for any guest operating system provides all the basic features, the custom video drivers that are installed with the Guest Additions provide you with extra high and non-standard video modes as well as accelerated video performance.

In addition, with Windows, Linux and Solaris guests, you can resize the virtual machine's window if the Guest Additions are installed. The video resolution in the guest will be automatically adjusted (as if you had manually entered an arbitrary resolution in the guest's display settings). Please see the section called “Resizing the machine's window” also.

Finally, if the Guest Additions are installed, 3D graphics and 2D video for guest applications can be accelerated; see the section called “Hardware-accelerated graphics”.

Seamless windows

With this feature, the individual windows that are displayed on the desktop of the virtual machine can be mapped on the host's desktop, as if the underlying application was actually running on the host. See the section called “Seamless windows” for details.

Generic host/guest communication channels

The Guest Additions enable you to control and monitor guest execution in ways other than those mentioned above. The so-called "guest properties" provide a generic string-based mechanism to exchange data bits between a guest and a host, some of which have special meanings for controlling and monitoring the guest; see the section called “Guest properties” for details.

Additionally, applications can be started in a guest from the host; see the section called “Guest control”.

Time synchronization

With the Guest Additions installed, VirtualBox can ensure that the guest's system time is better synchronized with that of the host.

For various reasons, the time in the guest might run at a slightly different rate than the time on the host. The host could be receiving updates via NTP and its own time might not run linearly. A VM could also be paused, which stops the flow of time in the guest for a shorter or longer period of time. When the wall clock time between the guest and host only differs slightly, the time synchronization service attempts to gradually and smoothly adjust the guest time in small increments to either "catch up" or "lose" time. When the difference is too great (e.g., a VM paused for hours or restored from saved state), the guest time is changed immediately, without a gradual adjustment.

The Guest Additions will re-synchronize the time regularly. See the section called “Tuning the Guest Additions time synchronization parameters” for how to configure the parameters of the time synchronization mechanism.

Shared clipboard

With the Guest Additions installed, the clipboard of the guest operating system can optionally be shared with your host operating system; see the section called “General settings”.

Automated logons (credentials passing)

For details, please see the section called “Automated guest logons”.

Each version of VirtualBox, even minor releases, ship with their own version of the Guest Additions. While the interfaces through which the VirtualBox core communicates with the Guest Additions are kept stable so that Guest Additions already installed in a VM should continue to work when VirtualBox is upgraded on the host, for best results, it is recommended to keep the Guest Additions at the same version.

Starting with VirtualBox 3.1, the Windows and Linux Guest Additions therefore check automatically whether they have to be updated. If the host is running a newer VirtualBox version than the Guest Additions, a notification with further instructions is displayed in the guest.

To disable this update check for the Guest Additions of a given virtual machine, set the value of its /VirtualBox/GuestAdd/CheckHostVersion guest property to 0; see the section called “Guest properties” for details.

Installing and Maintaining Guest Additions

Guest Additions are available for virtual machines running Windows, Linux, Solaris or OS/2. The following sections describe the specifics of each variant in detail.

Guest Additions for Windows

The VirtualBox Windows Guest Additions are designed to be installed in a virtual machine running a Windows operating system. The following versions of Windows guests are supported:

  • Microsoft Windows NT 4.0 (any service pack)

  • Microsoft Windows 2000 (any service pack)

  • Microsoft Windows XP (any service pack)

  • Microsoft Windows Server 2003 (any service pack)

  • Microsoft Windows Server 2008

  • Microsoft Windows Vista (all editions)

  • Microsoft Windows 7 (all editions)

Installation

In the "Devices" menu in the virtual machine's menu bar, VirtualBox has a handy menu item named "Install guest additions", which mounts the Guest Additions ISO file inside your virtual machine. A Windows guest should then automatically start the Guest Additions installer, which installs the Guest Additions into your Windows guest.

Note

For Direct 3D acceleration to work in a Windows Guest, you must install the Guest Additions in "Safe Mode"; see Chapter 14, Known limitations for details.

If you prefer to mount the additions manually, you can perform the following steps:

  1. Start the virtual machine in which you have installed Windows.

  2. Select "Mount CD/DVD-ROM" from the "Devices" menu in the virtual machine's menu bar and then "CD/DVD-ROM image". This brings up the Virtual Media Manager described in the section called “The Virtual Media Manager”.

  3. In the Virtual Media Manager, press the "Add" button and browse your host file system for the VBoxGuestAdditions.iso file:

    • On a Windows host, you can find this file in the VirtualBox installation directory (usually under C:\Program files\Oracle\VirtualBox ).

    • On Mac OS X hosts, you can find this file in the application bundle of VirtualBox. (Right click on the VirtualBox icon in Finder and choose Show Package Contents. There it is located in the Contents/MacOS folder.)

    • On a Linux host, you can find this file in the additions folder under where you installed VirtualBox (normally /opt/VirtualBox/).

    • On Solaris hosts, you can find this file in the additions folder under where you installed VirtualBox (normally /opt/VirtualBox).

  4. Back in the Virtual Media Manager, select that ISO file and press the "Select" button. This will mount the ISO file and present it to your Windows guest as a CD-ROM.

Unless you have the Autostart feature disabled in your Windows guest, Windows will now autostart the VirtualBox Guest Additions installation program from the Additions ISO. If the Autostart feature has been turned off, choose VBoxWindowsAdditions.exe from the CD/DVD drive inside the guest to start the installer.

The installer will add several device drivers to the Windows driver database and then invoke the hardware detection wizard.

Depending on your configuration, it might display warnings that the drivers are not digitally signed. You must confirm these in order to continue the installation and properly install the Additions.

After installation, reboot your guest operating system to activate the Additions.

Updating the Windows Guest Additions

Windows Guest Additions can be updated by running the installation program again, as previously described. This will then replace the previous Additions drivers with updated versions.

Alternatively, you may also open the Windows Device Manager and select "Update driver..." for two devices:

  1. the VirtualBox Graphics Adapter and

  2. the VirtualBox System Device.

For each, choose to provide your own driver and use "Have Disk" to point the wizard to the CD-ROM drive with the Guest Additions.

Unattended Installation

In order to allow for completely unattended guest installations, you can specify a command line parameter to the install launcher:

VBoxWindowsAdditions.exe /S

This automatically installs the right files and drivers for the corresponding platform (32- or 64-bit).

Note

Because of the drivers are not yet WHQL certified, you still might get some driver installation popups, depending on the Windows guest version.

For more options regarding unattended guest installations, consult the command line help by using the command:

VBoxWindowsAdditions.exe /?

Manual file extraction

If you would like to install the files and drivers manually, you can extract the files from the Windows Guest Additions setup by typing:

VBoxWindowsAdditions.exe /extract

To explicitly extract the Windows Guest Additions for another platform than the current running one (e.g. 64-bit files on a 32-bit system), you have to execute the appropriate platform installer (VBoxWindowsAdditions-x86.exe or VBoxWindowsAdditions-amd64.exe) with the /extract parameter.

Windows Vista networking

If, for some reason, you want to use an AMD PCNet card with Microsoft Windows Vista or later instead of the Intel E1000 card that VirtualBox provides by default, you will need to install a driver for that manually (see the section called “Virtual networking hardware”).

As a convenience, VirtualBox ships with a 32-bit driver for the AMD PCNet card, which comes with the Windows Guest Additions. If you install these in a 32-bit Vista guest, the driver will automatically be installed as well. If, for some reason, you would like to install the driver manually, you can extract the required files from the Windows Guest Additions setup. Please consult the section called “Manual file extraction” on how to achieve this. You will then find the AMD PCNet driver files in the x86\Network\AMD\netamd.inf subdirectory of the default install directory.

Unfortunately, there is no 64-bit driver available for the AMD PCNet card.

Guest Additions for Linux

Like the Windows Guest Additions, the VirtualBox Guest Additions for Linux take the form of a set of device drivers and system applications which may be installed in the guest operating system.

The following Linux distributions are officially supported:

  • Fedora as of Fedora Core 4;

  • Redhat Enterprise Linux as of version 3;

  • SUSE and openSUSE Linux as of version 9;

  • Ubuntu as of version 5.10.

Many other distributions are known to work with the Guest Additions.

The version of the Linux kernel supplied by default in SUSE and openSUSE 10.2, Ubuntu 6.10 (all versions) and Ubuntu 6.06 (server edition) contains a bug which can cause it to crash during startup when it is run in a virtual machine. The Guest Additions work in those distributions.

Note that some Linux distributions already come with VirtualBox Guest Additions or a part thereof. You may keep the distribution's version of the Guest Additions but often, these are not up to date and limited in functionality. Therefore, you can choose the install the Guest Additions that come with VirtualBox, overriding the already installed version. The VirtualBox Linux Guest Additions installer tries to detect existing installation and replace them but depending on how the distribution integrates the Guest Additions, they may require some manual interaction. It is highly recommended to take a snapshot of the virtual machine before overriding the installation.

Installing the Linux Guest Additions

The VirtualBox Guest Additions for Linux are provided on the same ISO CD-ROM as the Additions for Windows described above. They also come with an installation program guiding you through the setup process, although, due to the significant differences between Linux distributions, installation may be slightly more complex.

Installation generally involves the following steps:

  1. Before installing the Guest Additions, you will have to prepare your guest system for building external kernel modules. This works similarly as described in the section called “The VirtualBox kernel module”, except that this step must now be performed in your Linux guest instead of on a Linux host system, as described there.

    Again, as with Linux hosts, we recommend using DKMS for Linux guests as well. If it is not installed, use this command for Ubuntu/Debian systems:

    sudo apt-get install dkms

    or for Fedora systems:

    yum install dkms

    Make sure to nstall DKMS before installing the Linux Guest Additions.

  2. Mount the VBoxGuestAdditions.iso file as your Linux guest's virtual CD-ROM drive, exactly the same way as described for a Windows guest in the section called “Installation”.

  3. Change to the directory where your CD-ROM drive is mounted and execute as root:

    sh ./VBoxLinuxAdditions-x86.run

    In a 64-bit Linux guest, use VBoxLinuxAdditions-amd64.run instead.

For your convenience, the following step-by-step instructions have been verified to work for freshly installed copies of the most popular Linux distributions. After these preparational steps, you can execute the VirtualBox Guest Additions installer as described above.

Ubuntu 10.04 ("Lucid Lynx")
  1. In order to update your system to the latest version of the packets, open a terminal and as root, execute

    apt-get update

    followed by

    apt-get upgrade
  2. Install DKMS using

    apt-get install dkms
  3. Reboot your guest system in order to activate the updates and then proceed as described above.

Fedora 13 ("Goddard")
  1. In order to update your system to the latest version of the packets, open a terminal and as root, execute

    yum update
  2. Install DKMS and the GNU C compiler using

    yum install dkms

    followed by

    yum install gcc
  3. Reboot your guest system in order to activate the updates and then proceed as described above.

openSUSE 11.2
  1. In order to update your system to the latest version of the packets, open a terminal and as root, execute

    zypper update
  2. Install the make tool and the GNU C compiler using

    zypper install make gcc
  3. Reboot your guest system in order to activate the updates.

  4. Find out which kernel you are running using

    uname -a

    An example would be 2.6.31.12-0.2-default which refers to the "default" kernel. Then install the correct kernel development package. In the above example this would be

    zypper install kernel-default-devel
  5. Make sure that your running kernel (uname -a) and the kernel packages you have installed (rpm -qa kernel\*) have the exact same version number. Proceed with the installation as described above.

SuSE Linux Enterprise Desktop (SLED) 11
  1. In order to update your system to the latest version of the packets, open a terminal and as root, execute

    zypper update
  2. Install the GNU C compiler using

    zypper install gcc
  3. Reboot your guest system in order to activate the updates.

  4. Find out which kernel you are running using

    uname -a

    An example would be 2.6.27.19-5.1-default which refers to the "default" kernel. Then install the correct kernel development package. In the above example this would be

    zypper install kernel-syms kernel-source
  5. Make sure that your running kernel (uname -a) and the kernel packages you have installed (rpm -qa kernel\*) have the exact same version number. Proceed with the installation as described above.

Mandrake 2010
  1. Mandrake ships with the VirtualBox Guest Additions which will be replaced if you follow these steps.

  2. In order to update your system to the latest version of the packets, open a terminal and as root and execute

    urpmi --auto-update
  3. Reboot your system in order to activate the updates.

  4. Install DKMS using

    urpmi dkms

    and make sure to choose the correct kernel-devel package when asked by the installer (use uname -a to compare).

CentOS 5.5, Red Hat Enterprise Linux 5.5 and Oracle Enterprise Linux 5.5
  1. Add divider=10 to the kernel boot options in /etc/grub.conf to reduce the idle CPU load.

  2. To update your system to the latest version of the packets, open a terminal and as root, execute

    yum update
  3. Install the GNU C compiler and the kernel development packages using

    yum install gcc

    followed by

    yum install kernel-devel
  4. Reboot your guest system in order to activate the updates and then proceed as described above.

  5. Note that OpenGL support is not available unless you update to a later Linux kernel.

    In case Oracle Enterprise Linux does not find the required packages, you either have to install them from a different source (e.g. DVD) or use Oracle's public Yum server located at http://public-yum.oracle.com.

Debian 5 ("Lenny")
  1. In order to update your system to the latest version of the packets, open a terminal and as root, execute

    apt-get update

    followed by

    apt-get upgrade
  2. Install the make tool and the GNU C compiler using

    apt-get install make gcc
  3. Reboot your guest system in order to activate the updates.

  4. Determine the exact version of your kernel using uname -a and install the correct version of the linux-headers package, e.g. using

    apt-get install linux-headers-2.6.26-2-686

    Note that OpenGL support is not available unless you update to a later Linux kernel.

Manual setup of selected guest services

The VirtualBox Guest Additions contain several different drivers. If for any reason you do not wish to set them all up, you can install the Guest Additions using the following command:

  sh ./VBoxLinuxAdditions-x86.run no_setup

(substituting VBoxLinuxAdditions-amd64 on a 64-bit guest).

After this, you will need to at least compile the kernel modules by running the command

  /usr/lib/VBoxGuestAdditions/vboxadd setup

as root (you will need to replace lib by lib64 on some 64bit guests), and on older guests without the udev service you will need to add the vboxadd service to the default runlevel to ensure that the modules get loaded.

To setup the time synchronization service, run the command

  /usr/lib/VBoxGuestAdditions/vboxadd-service setup

and add the service vboxadd-service to the default runlevel. To set up the X11 and OpenGL part of the Guest Additions, run the command

  /usr/lib/VBoxGuestAdditions/vboxadd-x11 setup

(you do not need to enable any services for this).

To recompile the guest kernel modules, use this command:

  /usr/lib/VBoxGuestAdditions/vboxadd setup

After compilation you should reboot your guest to ensure that the new modules are actually used.

Video acceleration and high resolution graphics modes

In Linux guests, VirtualBox video acceleration is available through the X Window System. Typically, in today's Linux distributions, this will be the X.Org server. During the installation process, X will be set up to use the VirtualBox video driver shipped with the Guest Additions.

For Linux and Solaris guests, the X.org server version 1.3 or later is required for automatic resizing (the feature has been disabled on Fedora 9 guests due to a bug in the X server they supply). The server version can be checked with Xorg -version.

You can also send video mode hints using the VBoxManage tool.

If you are only using recent Linux guests systems, you can skip the rest of this section. On older guest systems, whatever graphics modes were set up before the installation will be used. If these modes do not suit your requirements, you can change your setup by editing the configuration file of the X server, usually found in /etc/X11/xorg.conf.

VirtualBox can use any default X graphics mode which fits into the virtual video memory allocated to the virtual machine, as described in the section called “General settings”. You can also add your own modes to the X server configuration file. You simply need to add them to the "Modes" list in the "Display" subsection of the "Screen" section. For example, the section shown here has a custom 2048x800 resolution mode added:

Section "Screen"
        Identifier    "Default Screen"
        Device        "VirtualBox graphics card"
        Monitor       "Generic Monitor"
        DefaultDepth  24
        SubSection "Display"
                Depth         24
                Modes         "2048x800" "800x600" "640x480"
        EndSubSection
EndSection

Updating the Linux Guest Additions

The Guest Additions can simply be updated by going through the installation procedure again with an updated CD-ROM image. This will replace the drivers with updated versions. You should reboot after updating the Guest Additions.

Uninstalling the Linux Guest Additions

If you have a version of the Guest Additions installed on your virtual machine and wish to remove it without installing new ones, you can do so by inserting the Guest Additions CD image into the virtual CD-ROM drive as described above and running the installer for the current Guest Additions with the "uninstall" parameter from the path that the CD image is mounted on in the guest:

sh ./VBoxLinuxAdditions-x86.run uninstall

With a 64-bit guest, use VBoxLinuxAdditions-amd64 instead. While this will normally work without issues, you may need to do some manual cleanup of the guest (particularly of the XFree86Config or xorg.conf file) in some cases, particularly if the Additions version installed or the guest operating system were very old, or if you made your own changes to the Guest Additions setup after you installed them.

Starting with version 3.1.0, you can uninstall the Additions by invoking

/opt/VBoxGuestAdditions-4.0.0/uninstall.sh

Please replace /opt/VBoxGuestAdditions-4.0.0 with the correct Guest Additions installation directory.

Guest Additions for Solaris

Like the Windows Guest Additions, the VirtualBox Guest Additions for Solaris take the form of a set of device drivers and system applications which may be installed in the guest operating system.

The following Solaris distributions are officially supported:

  • Solaris 11 Express;

  • Solaris 10 (u5 and higher);

  • Solaris Nevada/SXDE/SXCE (build 82 and higher);

  • OpenSolaris (Developer Preview 2 and higher; this includes OpenSolaris 2008.05, 2008.11 and 2009.06);

Other distributions may work if they are based on comparable software releases.

Installing the Solaris Guest Additions

The VirtualBox Guest Additions for Solaris are provided on the same ISO CD-ROM as the Additions for Windows and Linux described above. They also come with an installation program guiding you through the setup process.

Installation involves the following steps:

  1. Mount the VBoxGuestAdditions.iso file as your Solaris guest's virtual CD-ROM drive, exactly the same way as described for a Windows guest in the section called “Installation”.

    If in case the CD-ROM drive on the guest doesn't get mounted (observed on some versions of Solaris 10), execute as root:

    svcadm restart volfs
  2. Change to the directory where your CD-ROM drive is mounted and execute as root:

    pkgadd -G -d ./VBoxSolarisAdditions.pkg
  3. Choose "1" and confirm installation of the Guest Additions package. After the installation is complete, re-login to X server on your guest to activate the X11 Guest Additions.

Uninstalling the Solaris Guest Additions

The Solaris Guest Additions can be safely removed by removing the package from the guest. Open a root terminal session and execute:

pkgrm SUNWvboxguest

Updating the Solaris Guest Additions

The Guest Additions should be updated by first uninstalling the existing Guest Additions and then installing the new ones. Attempting to install new Guest Additions without removing the existing ones is not possible.

Guest Additions for OS/2

VirtualBox also ships with a set of drivers that improve running OS/2 in a virtual machine. Due to restrictions of OS/2 itself, this variant of the Guest Additions has a limited feature set; see Chapter 14, Known limitations for details.

The OS/2 Guest Additions are provided on the same ISO CD-ROM as those for the other platforms. As a result, mount the ISO in OS/2 as described previously. The OS/2 Guest Additions are located in the directory \32bit\OS2.

As we do not provide an automatic installer at this time, please refer to the readme.txt file in that directory, which describes how to install the OS/2 Guest Additions manually.

Shared folders

With the "shared folders" feature of VirtualBox, you can access files of your host system from within the guest system. This is similar how you would use network shares in Windows networks -- except that shared folders do not need require networking, only the Guest Additions. Shared Folders are supported with Windows (2000 or newer), Linux and Solaris guests.

Shared folders must physically reside on the host and are then shared with the guest, which uses a special file system driver in the Guest Addition to talk to the host. For Windows guests, shared folders are implemented as a pseudo-network redirector; for Linux and Solaris guests, the Guest Additions provide a virtual file system.

To share a host folder with a virtual machine in VirtualBox, you must specify the path of that folder and choose for it a "share name" that the guest can use to access it. Hence, first create the shared folder on the host; then, within the guest, connect to it.

There are several ways in which shared folders can be set up for a particular virtual machine:

  • In the window of a running VM, you can select "Shared folders" from the "Devices" menu, or click on the folder icon on the status bar in the bottom right corner.

  • If a VM is not currently running, you can configure shared folders in each virtual machine's "Settings" dialog.

  • From the command line, you can create shared folders using VBoxManage, as follows:

    VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "C:\test"

    See the section called “VBoxManage sharedfolder add/remove” for details.

There are two types of shares:

  1. VM shares which are only available to the VM for which they have been defined;

  2. transient VM shares, which can be added and removed at runtime and do not persist after a VM has stopped; for these, add the --transient option to the above command line.

Shared folders have read/write access to the files at the host path by default. To restrict the guest to have read-only access, create a read-only shared folder. This can either be achieved using the GUI or by appending the parameter --readonly when creating the shared folder with VBoxManage.

Starting with version 4.0, VirtualBox shared folders also support symbolic links (symlinks), under the following conditions:

  1. The host operating system must support symlinks (i.e. a Mac, Linux or Solaris host is required).

  2. Currently only Linux Guest Additions support symlinks.

Manual mounting

You can mount the shared folder from inside a VM the same way as you would mount an ordinary network share:

  • In a Windows guest, shared folders are browseable and therefore visible in Windows Explorer. So, to attach the host's shared folder to your Windows guest, open Windows Explorer and look for it under "My Networking Places" -> "Entire Network" -> "VirtualBox Shared Folders". By right-clicking on a shared folder and selecting "Map network drive" from the menu that pops up, you can assign a drive letter to that shared folder.

    Alternatively, on the Windows command line, use the following:

    net use x: \\vboxsvr\sharename

    While vboxsvr is a fixed name (note that vboxsrv would also work), replace "x:" with the drive letter that you want to use for the share, and sharename with the share name specified with VBoxManage.

  • In a Linux guest, use the following command:

    mount -t vboxsf [-o OPTIONS] sharename mountpoint

    To mount a shared folder during boot, add the following entry to /etc/fstab:

    sharename   mountpoint   vboxsf   defaults  0   0
  • In a Solaris guest, use the following command:

    mount -F vboxfs [-o OPTIONS] sharename mountpoint

    Replace sharename (use lowercase) with the share name specified with VBoxManage or the GUI, and mountpoint with the path where you want the share to be mounted on the guest (e.g. /mnt/share). The usual mount rules apply, that is, create this directory first if it does not exist yet.

    Here is an example of mounting the shared folder for the user "jack" on Solaris:

    $ id
    uid=5000(jack) gid=1(other)
    $ mkdir /export/home/jack/mount
    $ pfexec mount -F vboxfs -o uid=5000,gid=1 jackshare /export/home/jack/mount
    $ cd ~/mount
    $ ls
    sharedfile1.mp3 sharedfile2.txt
    $

    Beyond the standard options supplied by the mount command, the following are available:

    iocharset CHARSET

    to set the character set used for I/O operations (utf8 by default) and

    convertcp CHARSET

    to specify the character set used for the shared folder name (utf8 by default).

    The generic mount options (documented in the mount manual page) apply also. Especially useful are the options uid, gid and mode, as they allow access by normal users (in read/write mode, depending on the settings) even if root has mounted the filesystem.

Automatic mounting

Starting with version 4.0, VirtualBox can mount shared folders automatically, at your option. If automatic mounting is enabled for a specific shared folder, the Guest Additions will automatically mount that folder as soon as a user logs into the guest OS. The details depend on the guest OS type:

  • With Windows guests, any auto-mounted shared folder will receive its own drive letter (e.g. E:) depending on the free drive letters remaining in the guest.

    If there no free drive letters left, auto-mounting will fail; as a result, the number of auto-mounted shared folders is typically limited to 22 or less with Windows guests.

  • With Linux guests, auto-mounted shared folders are mounted into the /media directory, along with the prefix sf_. For example, the shared folder myfiles would be mounted to /media/sf_myfiles on Linux and /mnt/sf_myfiles on Solaris.

    The guest property /VirtualBox/GuestAdd/SharedFolders/MountPrefix determines the prefix that is used. Change that guest property to a value other than "sf" to change that prefix; see the section called “Guest properties” for details.

    Note

    Access to auto-mounted shared folders is only granted to the user group vboxsf, which is created by the VirtualBox Guest Additions installer. Hence guest users have to be member of that group to have read/write access or to have read-only access in case the folder is not mapped writable.

    To change the mount directory to something other than /media, you can set the guest property /VirtualBox/GuestAdd/SharedFolders/MountDir.

  • Solaris guests behave like Linux guests except that /mnt is used as the default mount directory instead of /media.

To have any changes to auto-mounted shared folders applied while a VM is running, the guest OS needs to be rebooted. (This applies only to auto-mounted shared folders, not the ones which are mounted manually.)

Hardware-accelerated graphics

Hardware 3D acceleration (OpenGL and Direct3D 8/9)

The VirtualBox Guest Additions contain experimental hardware 3D support for Windows, Linux and Solaris guests.[17]

With this feature, if an application inside your virtual machine uses 3D features through the OpenGL or Direct3D 8/9 programming interfaces, instead of emulating them in software (which would be slow), VirtualBox will attempt to use your host's 3D hardware. This works for all supported host platforms (Windows, Mac, Linux, Solaris), provided that your host operating system can make use of your accelerated 3D hardware in the first place.

The 3D acceleration currently has the following preconditions:

  1. It is only available for certain Windows, Linux and Solaris guests. In particular:

    • 3D acceleration with Windows guests requires Windows 2000, Windows XP, Vista or Windows 7. Both OpenGL and Direct3D 8/9 (not with Windows 2000) are supported (experimental).

    • OpenGL on Linux requires kernel 2.6.27 and higher as well as X.org server version 1.5 and higher. Ubuntu 10.10 and Fedora 14 have been tested and confirmed as working.

    • OpenGL on Solaris guests requires X.org server version 1.5 and higher.

  2. The Guest Additions must be installed.

    Note

    For Direct 3D acceleration to work in a Windows Guest, VirtualBox needs to replace Windows system files in the virtual machine. As a result, the Guest Additions installation program offers Direct 3D acceleration as an option that must be explicitly enabled. Also, you must install the Guest Additions in "Safe Mode"; see Chapter 14, Known limitations for details.

  3. Because 3D support is still experimental at this time, it is disabled by default and must be manually enabled in the VM settings (see the section called “General settings”).

    Note

    Enabling 3D acceleration may expose security holes to malicious software running in the guest. The third-party code that VirtualBox uses for this purpose (Chromium) is not hardened enough to prevent every risky 3D operation on the host.

Technically, VirtualBox implements this by installing an additional hardware 3D driver inside your guest when the Guest Additions are installed. This driver acts as a hardware 3D driver and reports to the guest operating system that the (virtual) hardware is capable of 3D hardware acceleration. When an application in the guest then requests hardware acceleration through the OpenGL or Direct3D programming interfaces, these are sent to the host through a special communication tunnel implemented by VirtualBox, and then the host performs the requested 3D operation via the host's programming interfaces.

Hardware 2D video acceleration for Windows guests

Starting with version 3.1, the VirtualBox Guest Additions contain experimental hardware 2D video acceleration support for Windows guests.

With this feature, if an application (e.g. a video player) inside your Windows VM uses 2D video overlays to play a movie clip, then VirtualBox will attempt to use your host's video acceleration hardware instead of performing overlay stretching and color conversion in software (which would be slow). This currently works for Windows, Linux and Mac host platforms, provided that your host operating system can make use of 2D video acceleration in the first place.

The 2D video acceleration currently has the following preconditions:

  1. It is only available for Windows guests (XP or later).

  2. The Guest Additions must be installed.

  3. Because 2D support is still experimental at this time, it is disabled by default and must be manually enabled in the VM settings (see the section called “General settings”).

Technically, VirtualBox implements this by exposing video overlay DirectDraw capabilities in the Guest Additions video driver. The driver sends all overlay commands to the host through a special communication tunnel implemented by VirtualBox. On the host side, OpenGL is then used to implement color space transformation and scaling

Seamless windows

With the "seamless windows" feature of VirtualBox, you can have the windows that are displayed within a virtual machine appear side by side next to the windows of your host. This feature is supported for the following guest operating systems (provided that the Guest Additions are installed):

  • Windows guests (support added with VirtualBox 1.5);

  • Linux or Solaris guests with an X.org server version 1.3 or higher[18] (support added with VirtualBox 1.6). The exception is Fedora 9, due to a bug in its X server.

After seamless windows are enabled (see below), VirtualBox suppresses the display of the Desktop background of your guest, allowing you to run the windows of your guest operating system seamlessly next to the windows of your host:

To enable seamless mode, after starting the virtual machine, press the Host key (normally the right control key) together with "L". This will enlarge the size of the VM's display to the size of your host screen and mask out the guest operating system's background. To go back to the "normal" VM display (i.e. to disable seamless windows), press the Host key and "L" again.

Guest properties

Starting with version 2.1, VirtualBox allows for requesting certain properties from a running guest, provided that the VirtualBox Guest Additions are installed and the VM is running. This is good for two things:

  1. A number of predefined VM characteristics are automatically maintained by VirtualBox and can be retrieved on the host, e.g. to monitor VM performance and statistics.

  2. In addition, arbitrary string data can be exchanged between guest and host. This works in both directions.

To accomplish this, VirtualBox establishes a private communication channel between the VirtualBox Guest Additions and the host, and software on both sides can use this channel to exchange string data for arbitrary purposes. Guest properties are simply string keys to which a value is attached. They can be set (written to) by either the host and the guest, and they can also be read from both sides.

In addition to establishing the general mechanism of reading and writing values, a set of predefined guest properties is automatically maintained by the VirtualBox Guest Additions to allow for retrieving interesting guest data such as the guest's exact operating system and service pack level, the installed version of the Guest Additions, users that are currently logged into the guest OS, network statistics and more. These predefined properties are all prefixed with /VirtualBox/ and organized into a hierarchical tree of keys.

Some of this runtime information is shown when you select "Session Information Dialog" from a virtual machine's "Machine" menu.

A more flexible way to use this channel is via the VBoxManage guestproperty command set; see the section called “VBoxManage guestproperty” for details. For example, to have all the available guest properties for a given running VM listed with their respective values, use this:

$ VBoxManage guestproperty enumerate "Windows Vista III"
VirtualBox Command Line Management Interface Version 4.0.0
(C) 2005-2010 Oracle Corporation
All rights reserved.

Name: /VirtualBox/GuestInfo/OS/Product, value: Windows Vista Business Edition,
    timestamp: 1229098278843087000, flags:
Name: /VirtualBox/GuestInfo/OS/Release, value: 6.0.6001,
    timestamp: 1229098278950553000, flags:
Name: /VirtualBox/GuestInfo/OS/ServicePack, value: 1,
    timestamp: 1229098279122627000, flags:
Name: /VirtualBox/GuestAdd/InstallDir,
    value: C:/Program Files/Oracle/VirtualBox
    Guest Additions, timestamp: 1229098279269739000, flags:
Name: /VirtualBox/GuestAdd/Revision, value: 40720,
    timestamp: 1229098279345664000, flags:
Name: /VirtualBox/GuestAdd/Version, value: 4.0.0,
    timestamp: 1229098279479515000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxControl.exe, value: 4.0.0r40720,
    timestamp: 1229098279651731000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxHook.dll, value: 4.0.0r40720,
    timestamp: 1229098279804835000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxDisp.dll, value: 4.0.0r40720,
    timestamp: 1229098279880611000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxMRXNP.dll, value: 4.0.0r40720,
    timestamp: 1229098279882618000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxService.exe, value: 4.0.0r40720,
    timestamp: 1229098279883195000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxTray.exe, value: 4.0.0r40720,
    timestamp: 1229098279885027000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxGuest.sys, value: 4.0.0r40720,
    timestamp: 1229098279886838000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxMouse.sys, value: 4.0.0r40720,
    timestamp: 1229098279890600000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxSF.sys, value: 4.0.0r40720,
    timestamp: 1229098279893056000, flags:
Name: /VirtualBox/GuestAdd/Components/VBoxVideo.sys, value: 4.0.0r40720,
    timestamp: 1229098279895767000, flags:
Name: /VirtualBox/GuestInfo/OS/LoggedInUsers, value: 1,
    timestamp: 1229099826317660000, flags:
Name: /VirtualBox/GuestInfo/OS/NoLoggedInUsers, value: false,
    timestamp: 1229098455580553000, flags:
Name: /VirtualBox/GuestInfo/Net/Count, value: 1,
    timestamp: 1229099826299785000, flags:
Name: /VirtualBox/HostInfo/GUI/LanguageID, value: C,
    timestamp: 1229098151272771000, flags:
Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 192.168.2.102,
    timestamp: 1229099826300088000, flags:
Name: /VirtualBox/GuestInfo/Net/0/V4/Broadcast, value: 255.255.255.255,
    timestamp: 1229099826300220000, flags:
Name: /VirtualBox/GuestInfo/Net/0/V4/Netmask, value: 255.255.255.0,
    timestamp: 1229099826300350000, flags:
Name: /VirtualBox/GuestInfo/Net/0/Status, value: Up,
    timestamp: 1229099826300524000, flags:
Name: /VirtualBox/GuestInfo/OS/LoggedInUsersList, value: username,
    timestamp: 1229099826317386000, flags:

To query the value of a single property, use the "get" subcommand like this:

$ VBoxManage guestproperty get "Windows Vista III"
         "/VirtualBox/GuestInfo/OS/Product"
VirtualBox Command Line Management Interface Version 4.0.0
(C) 2005-2010 Oracle Corporation
All rights reserved.

Value: Windows Vista Business Edition

To add or change guest properties from the guest, use the tool VBoxControl. This tool is included in the Guest Additions of VirtualBox 2.2 or later. When started from a Linux guest, this tool requires root privileges for security reasons:

$ sudo VBoxControl guestproperty enumerate
VirtualBox Guest Additions Command Line Management Interface Version 4.0.0
(C) 2009-2010 Oracle Corporation
All rights reserved.

Name: /VirtualBox/GuestInfo/OS/Release, value: 2.6.28-18-generic,
    timestamp: 1265813265835667000, flags: <NULL>
Name: /VirtualBox/GuestInfo/OS/Version, value: #59-Ubuntu SMP Thu Jan 28 01:23:03 UTC 2010,
    timestamp: 1265813265836305000, flags: <NULL>
      ...

For more complex needs, you can use the VirtualBox programming interfaces; see Chapter 11, VirtualBox programming interfaces.

Guest control

Starting with version 3.2, the Guest Additions of VirtualBox allow starting applications inside a VM from the host system.

For this to work, the application needs to be installed inside the guest; no additional software needs to be installed on the host. Additionally, text mode output (to stdout and stderr) can be shown on the host for further processing along with options to specify user credentials and a timeout value (in milliseconds) to limit time the application is able to run.

This feature can be used to automate deployment of software within the guest.

Starting with version 4.0, the Guest Additions for Windows allow for automatic updating (only already installed Guest Additions 4.0 or later). Also, copying files from host to the guest as well as remotely creating guest directories is available.

To use these features, use the VirtualBox command line, see the section called “VBoxManage guestcontrol”.

Memory overcommitment

In server environments with many VMs; the Guest Additions can be used to share physical host memory between several VMs, reducing the total amount of memory in use by the VMs. If memory usage is the limiting factor and CPU resources are still available, this can help with packing more VMs on each host.

Memory ballooning

Starting with version 3.2, the Guest Additions of VirtualBox can change the amount of host memory that a VM uses while the machine is running. Because of how this is implemented, this feature is called "memory ballooning".

Note

VirtualBox supports memory ballooning only on 64-bit hosts, and it is not supported on Mac OS X hosts.

Normally, to change the amount of memory allocated to a virtual machine, one has to shut down the virtual machine entirely and modify its settings. With memory ballooning, memory that was allocated for a virtual machine can be given to another virtual machine without having to shut the machine down.

When memory ballooning is requested, the VirtualBox Guest Additions (which run inside the guest) allocate physical memory from the guest operating system on the kernel level and lock this memory down in the guest. This ensures that the guest will not use that memory any longer: no guest applications can allocate it, and the guest kernel will not use it either. VirtualBox can then re-use this memory and give it to another virtual machine.

The memory made available through the ballooning mechanism is only available for re-use by VirtualBox. It is not returned as free memory to the host. Requesting balloon memory from a running guest will therefore not increase the amount of free, unallocated memory on the host. Effectively, memory ballooning is therefore a memory overcommitment mechanism for multiple virtual machines while they are running. This can be useful to temporarily start another machine, or in more complicated environments, for sophisticated memory management of many virtual machines that may be running in parallel depending on how memory is used by the guests.

At this time, memory ballooning is only supported through VBoxManage. Use the following command to increase or decrease the size of the memory balloon within a running virtual machine that has Guest Additions installed:

VBoxManage controlvm "VM name" guestmemoryballoon <n>

where "VM name" is the name or UUID of the virtual machine in question and <n> is the amount of memory to allocate from the guest in megabytes. See the section called “VBoxManage controlvm” for more information.

You can also set a default balloon that will automatically be requested from the VM every time after it has started up with the following command:

VBoxManage modifyvm "VM name" --guestmemoryballoon <n>

By default, no balloon memory is allocated. This is a VM setting, like other modifyvm settings, and therefore can only be set while the machine is shut down; see the section called “VBoxManage modifyvm”.

Page Fusion

Whereas memory ballooning simply reduces the amount of RAM that is available to a VM, Page Fusion works differently: it avoids memory duplication between several similar running VMs.

In a server environment running several similar VMs (e.g. with identical operating systems) on the same host, lots of memory pages are identical. VirtualBox's Page Fusion technology, introduced with VirtualBox 3.2, is a novel technique to efficiently identify these identical memory pages and share them between multiple VMs.

Note

VirtualBox supports Page Fusion only on 64-bit hosts, and it is not supported on Mac OS X hosts. Page Fusion currently works only with Windows guests (2000 and later).

The more similar the VMs on a given host are, the more efficiently Page Fusion can reduce the amount of host memory that is in use. It therefore works best if all VMs on a host run identical operating systems (e.g. Windows XP Service Pack 2). Instead of having a complete copy of each operating system in each VM, Page Fusion identifies the identical memory pages in use by these operating systems and eliminates the duplicates, sharing host memory between several machines ("deduplication"). If a VM tries to modify a page that has been shared with other VMs, a new page is allocated again for that VM with a copy of the shared page ("copy on write"). All this is fully transparent to the virtual machine.

You may be familiar with this kind of memory overcommitment from other hypervisor products, which call this feature "page sharing" or "same page merging". However, Page Fusion differs significantly from those other solutions, whose approaches have several drawbacks:

  1. Traditional hypervisors scan all guest memory and compute checksums (hashes) for every single memory page. Then, they look for pages with identical hashes and compare the entire content of those pages; if two pages produce the same hash, it is very likely that the pages are identical in content. This, of course, can take rather long, especially if the system is not idling. As a result, the additional memory only becomes available after a significant amount of time (this can be hours or even days!). Even worse, this kind of page sharing algorithm generally consumes significant CPU resources and increases the virtualization overhead by 10-20%.

    Page Fusion in VirtualBox uses logic in the VirtualBox Guest Additions to quickly identify memory cells that are most likely identical across VMs. It can therefore achieve most of the possible savings of page sharing almost immediately and with almost no overhead.

  2. Page Fusion is also much less likely to be confused by identical memory that it will eliminate just to learn seconds later that the memory will now change and having to perform a highly expensive and often service-disrupting reallocation.

At this time, Page Fusion can only be controlled with VBoxManage, and only while a VM is shut down. To enable Page Fusion for a VM, use the following command:

VBoxManage modifyvm "VM name" --pagefusion on

You can observe Page Fusion operation using some metrics. RAM/VMM/Shared shows the total amount of fused pages, whereas the per-VM metric Guest/RAM/Usage/Shared will return the amount of fused memory for a given VM. Please refer to the section called “VBoxManage metrics” for information on how to query metrics.



[17] OpenGL support for Windows guests was added with VirtualBox 2.1; support for Linux and Solaris followed with VirtualBox 2.2. With VirtualBox 3.0, Direct3D 8/9 support was added for Windows guests. OpenGL 2.0 is now supported as well.

[18] The X server version is not the same as the version of the entire X.org suite. You can type X -version in a terminal to find out about the X.org server version level that is currently installed.