VirtualBox Linux Guest customization

VirtualBox is a virtual pc emulator like vmware. It has many of the features vmware has, as well as some of its own. It is in constant development and new features are implemented all the time. eg. version 2.2 introduced OpenGL 3D acceleration support for Linux and Solaris guests. It has a nice GUI interface (Qt and/or SDL) or command line tools for managing virtual machines. Headless operation is also supported. Running iTunes under VirtualBox is the only way (currently) to sync iPod Touch/iPhone firmware 3.0+.




This is the basic GPL licensed VirtualBox suite, which can be found in the community repository.
This PUEL licensed extension pack is free for personal use. You can download it from the AUR. It features an RPD server, USB 2.0 support and PXE boot for Intel cards.

Install the basic package:

Optionally install qt in order to use the GUI:

Running VirtualBox

Now, add the desired username to the vboxusers group:

Build the required modules:

Lastly, edit /etc/rc.conf and add vboxdrv to the MODULES array in order to load the VirtualBox drivers at startup:

To load the module manually:

To start Virtualbox:



VirtualBox guests may be networked through various methods; among them, there’s #NAT and #Bridged networking. Using the #NAT method is the simplest and the default for new virtual machines.

The VirtualBox manual covers host-only and internal network options. These have been omitted due to them being, for the most part, OS agnostic.


From VirtualBox:

  • access the VM’s Settings menu;
  • click on Network from the list to the left; finally,
  • in the Attached to drop-down list, select NAT.

VirtualBox’s bundled DHCP server enables the guest system to be configured with DHCP. The NAT IP address on the first card is, on the second and so on.


Bridged networking may be setup through various methods; among them, there’s the native way, which requires minimal setup at the expense of having less control. For other methods, see Advanced VirtualBox Networking. Since newer versions, VirtualBox can bridge between a guest and a wireless host interface without the help of third party utilities.

Before continuing, load the required module:

From VirtualBox:

  • access the VM’s Settings menu;
  • click on Network from the list to the left;
  • in the Attached to drop-down list, select Bridged Adapter; finally,
  • in the Name drop-down list, select the name of the host interface that’s connected to the network that the guest OS should be part of.

Start the virtual machine and configure its network as usual; e.g., DHCP or static.

Guest additions

The Guest Additions make the shared folders feature available, improve video card acceleration support, and enable bi-directional clipboard between the guest and host. Mouse integration is another feature, taking away the need of releasing the mouse after using it in the guest.

Arch Linux guests

Do the following instructions while in the VM.

Install the required package:

Now, mount the newly installed ISO:

Install the kernel headers:

Mount the VirtualBox ISO:

for i686 systems (32 bit):

for x86_64 systems (64 bit):

The script will build and install the kernel modules, install the Xorg drivers and create init scripts. It will most probably print out errors about init scripts and run levels, which can be ignored.

Among the files created, /etc/rc.d/rc.vboxadd will load the Guest Additions on demand. Add it to the DAEMONS array:

Then execute as before. Before adding rc.vboxadd to DAEMONS check /etc/rc.local for commands to load the vboxadd daemons put by the installation script.

Windows guests

After installing Windows (XP etc.) on your virtual machine, simply select Devices ? Install Guest Additions…

This will mount the iso image and windows should then automatically launch the guest additions installer. Follow the instructions to the end.

Keyboard and mouse between the host and the guest

  • To capture the keyboard and mouse, click the mouse inside the virtual machine display.
  • To uncapture, press right Ctrl.

To get seamless mouse integration between host and guest, install the #Guest Additions inside the guest.

When generating the guests’ xorg.conf with X -configure, the InputDevice section may feature the mouse driver. After installing the Guest Additions, replace mouse with vboxmouse and then restart X or reboot the guest.

Alternatively, add the following to the guest’s xorg.conf:

Using full resolution of the host system in the guest

Set the resolution of your guest in the grub boot script /boot/grub/menu.lst, i.e. add the correct vga code to the kernel command line. For a resolution of 1280×1024, this would e.g. look like

Add the resolution to /etc/X11/xorg.conf, e.g.

Sharing folders between the host and the guest

In the settings of the virtual machine go to shared folders tab and add the folders you want to share.

  • NOTE: You need to install Guest Additions in order to use this feature.

In a Linux host, create one or more folders for sharing files, then set the shared folders via the virtualbox menu (guest window).

In a Windows guest, starting with VirtualBox 1.5.0, shared folders are browseable and are therefore visible in Windows Explorer. Open Windows Explorer and look for it under My Networking Places ? Entire Network ? VirtualBox Shared Folders.

Launch the windows explorer (run explorer command) to browse the network places -> expand with the (+) sign : entire network ? VirtualBox shared folders ? \\Vboxsvr ? then you can now expand all your configured shared folders here, and set up shortcuts for linux folders in the guest filesystem. You can alternatively use the “Add network place wizard”, and browse to “VBoxsvr”.

Alternatively, on the Windows command line, you can also use the following:

While VBOXSVR is a fixed name, 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 Windows guest, to improve loading and saving files (e.g. MS Office) by VirtualBox Shared Folders edit c:\windows\system32\drivers\etc\hosts as below:

In a Linux guest, use the following command:

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

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

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

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

Getting audio to work in the guest machine

In the machine settings, go to the audio tab and select the correct driver according to your sound system (ALSA, OSS or PulseAudio).

Setting up the RAM and video memory for the guest

You can change the default values by going to Settings ? General.

Setting up CD-ROM for the guest

You can change the default values by going to Settings ? CD/DVD-ROM.

Check mount CD/DVD drive and select one of the following options.

Enabling D3D acceleration in Windows guests

Recent versions of Virtualbox have support for accelerating OpenGL inside guests. This can be enabled with a simple checkbox in the machine’s settings, right below where video ram is set, and installing the Virtualbox guest additions. However, most Windows games use Direct3D (part of DirectX), not OpenGL, and are thus not helped by this method. However, it is possible to gain accelerated Direct3D in your Windows guests by borrowing the d3d libraries from Wine, which translate d3d calls into OpenGL, which is then accelerated.

After enabling OpenGL acceleration as described above, go to in your Windows guest and grab the “Latest version (Installer):”. Reboot the guest into safe mode (press F8 before the Windows screen appears but after the Virtualbox screen disappears), and install wined3d, accepting the defaults during the install. (You may check the box for DirectX 10 support if you like, dont touch anything else.) Reboot back to normal mode and you should have accelerated Direct3D.

Note: This hack may or may not work for some games depending on what hardware checks they make and what parts of D3D they use.
Note: This has only been tried on Windows XP and Windows 7 RC guests AFAIK, and does not work on the Windows 7 guest. If you have experience with this on a different windows version, please add that data here.

Virtualized OS setup

Virtualbox needs to be setup to virtualize another operating system.

Test a liveCD/DVD

Click the ‘New’ button to create a new virtual environment. Name it appropriately and select Operating System type and version. Select base memory size (note: most operating systems will need at least 512MB to function properly). Create a new hard disk image (a hard disk image is a file that will contain the operating system’s filesystem and files).

When the new image has been created, click ‘Settings’, then CD/DVD-ROM, check ‘Mount CD/DVD Drive’ then select an ISO image.


Rebuild the vboxdrv module

Note that any time your kernel version changes (due to an upgrade, recompile, etc.) you must also rebuild the VirtualBox kernel modules.

Ensure that kernel26-headers is still installed, and run the following command:

This will build the VirtualBox kernel modules for the currently running kernel; if you have just upgraded your kernel package, reboot before trying to rebuild your kernel modules.

After rebuilding the module, do not forget to load it with

vboxdrv and vboxnetflt should be in the MODULES=() section of your /etc/rc.conf

If you are using an old virtualbox_bin package built from AUR, run:

If you need to rebuild the Virtual Box Additions in a guest installation of Arch Linux, use this command:

Compact a disk image

See How to compact a VirtualBox virtual disk image (VDI)

Increase the size of a virtual hard drive for a Windows guest


If you find that you are running out of space due to the small hard drive size you selected when created your VM, you can take the following steps:

Create a new vdi in ~/.VirtualBox/HardDisks by running:

where size is in mb, in this example 10000MB ~= 10GB, and new.vdi is name of new hard drive to be created.

Next the old vdi needs to be cloned to the new vdi, this may take some time so wait while it occurs:

Detach old harddrive and attach new hard drive, replace VMName with whatever you called your VM:

Boot the VM, run Partition Wizard 5 to resize the partition on the fly, and reboot.

Remove old vdi from VirtualBox and delete

Windows Xp and Nokia phones

To get working Windows XP and Nokia phones with Pc Suite mode, Virtualbox needs two simple steps:

1. Add a rule to udev with /etc/udev/rules.d/40-permissions.rules:

2. Create the group usbfs and add its user to it

After a logout, connect a Nokia phone with PC Suite mode and start Windows XP to test new rule.

Migrating from another VM

The qemu-img program can be used to convert images from one format to another, or add compression or encryption to an image.

Converting from QEMU images

To convert a QEMU image for use with VirtualBox, first convert it to raw format, then use VirtualBox’s conversion utility to convert and compact it in its native format.

Converting from VMware images


This may not be needed anymore with recent virtualbox versions (to be confirmed)

Tips and tricks

Getting Web-cams and other USB devices to detect

Make sure you filter any devices that are not a keyboard or a mouse so they don’t start up at boot and this insures that Windows will detect the device at start-up.

Sending a CTRL+ALT+F1 to the Guest

If your guest O/S is a Linux distro, and you want to open a new tty text shell or exit X via typing Ctrl+Alt+F1, you can easily send this command to the guest O/S simply by hitting your ‘Host Key’ (usually the Ctrl in the Right side of your keyboard) + F1 or F2, etc.

Starting VMs at system boot on headless servers

Add this line to /etc/rc.local

Where PREFERRED_USER is the user profile that contains the VM definitions and .vdi files. This will start the VM with a RDP server running on port 3389. To determine the available VMs for a user:

To suspend the VM:

Accessing server on VM from host

To access apache on a VM from the Host machine ONLY, simply execute the following lines on the Host:

Where 8888 is the port the host should listen on and 80 is the port the VM will send Apache’s signal on. To use a port lower than 1024 on the host machine changes need to be made to the firewall on the host machine. This can also be set up to work with SSH, etc.. by changing “Apache” to whatever service and using different ports.

Note: “pcnet” refers to the network card of the VM. If you use an Intel card in your VM settings change “pcnet” to “e1000”

It might also be necessary to allow connections from the outside to the server in your VM. E.g. if the guest OS is Arch, you may want to add the line

to your /etc/hosts.allow file.


While VirtualBox can mount ISO images without a problem, there are some image formats which cannot reliably be converted to ISO. For instance, ccd2iso ignores .ccd and .sub files, which can give disk images with broken files. cdemu, fuseiso, and MagicISO will do the same. In this case there is no choice but to use Daemon Tools inside VirtualBox.

Recent Daemon Tools versions won’t install, so use this old one: [2]

Using VirtualBox on a USB key

When using VirtualBox on a USB key, for example to start an installed machine with an ISO image, you will manually have to create VDMKs from the existing drives. However, once the new VMDKs are saved and you move on to another machine, you may experience problems launching an appropriate machine again. To get rid of this issue, you can use the following script to launch VirtualBox. This script will clean up and unregister old VMDK files and it will create new, proper VMDKs for you:

Note that your user has to be added to the “disk” group to create VMDKs out of existing drives.


An open source, AJAX implementation of the VirtualBox user interface written in PHP. As a modern web interface, it allows you to access and control remote VirtualBox instances. Much of its verbage and some of its code is based on the (inactive) vboxweb project. It allows the used to remotely, graphically, administer their virtual machines without having to log in to their headless VirtualBox servers.

This requires the PUEL edition for VirtualBox.

An installation guide is available here:

Arch Linux users should uncomment these 2 extensions in /etc/php/php.ini

Running Arch Linux as a guest

To install guest additions with support for Xorg follow these steps:

Note: Guest additions from Virtualbox 3.2.8 do not support Xorg 1.9. Refer to Virtualbox ticket #7306 for an updated iso.
Note: There is a new Version of guest additions available here.

  • Go to Virtualbox folder
  • Delete the vboxguestadditions.iso
  • Copy vboxguestadditions_3.2.9*.iso to your virtualbox folder and rename it to vboxguestadditions.iso
  • sudo mount /dev/cdrom /media/cd
  • sudo sh /media/cd/VBoxLinuxAdditions-amd64/

Enjoy the guest additions.

Note: Run the following steps as root
  • install entire xorg group: (is everything actually required?)
  • install dependencies needed to build the guest additions:
  • mount and install VirtualBox guest additions
Note: If X didn’t work after you finished following steps , you may install virtualbox-ose-additions-modules from community repo instead of guest additions from it’s ISO.

then go ahead.

  • create /etc/X11/xorg.conf with the following contents:

Note: It is not required to add rc.vboxadd to DAEMONS because it is added to /etc/rc.local automatically
Note: Run the following steps while logged into your user account
  • add /usr/bin/VBoxClient-all & to the top of ~/.xinitrc (even if ~/.xinitrc does not exist)
Note: If you upgrade the kernel in the Virtual Machine you will need to re-install the Guest Additions in order for some features to work properly.

If you need to rebuild the Virtual Box Additions in a guest installation of Arch Linux, use this command:

Copy and paste is not working in Arch guests!

You forgot to start VBoxclient-all. See above.

Enabling OpenGL acceleration in Arch Linux guests

Due to a bug in the VirtualBox guest addition setup scripts (as of VBox 3.1.2), simply ticking the “3D acceleration” checkbox in the virtual machine settings and installing the guest additions won’t enable 3D acceleration for OpenGL applications under X for Arch Linux guests (and possibly others). In order to still get OpenGL acceleration, a bit of manual intervention is necessary after installing the guest additions. As root, run:

Also make sure the user starting X in the guest is in the video group.

Note: Don’t compare before-after performance using glxgears! You may get a lot less FPS due to now-working vsync support. Compare performance using a real, heavy 3D application (like a game).

External links

Author: stratus

Laisser un commentaire