From ArchWiki
Revision as of 07:49, 22 August 2008 by Rasat (Talk | contribs) (Key and mouse capture between the host and the guest)

Jump to: navigation, search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

What is VirtualBox

VirtualBox is a virtual pc emulator like vmware. It has many of the features vmware has, as well as some of its own.


VirtualBox is available in two editions: VirtualBox (OSE) and VirtualBox (Personal Use and Evaluation License (PUEL))

VirtualBox (OSE)

VirtualBox (OSE) is the open source version of VirtualBox, which can be found in the community repository. It lacks some features such as USB device support and the built-in RDP server.

VirtualBox (PUEL)

VirtualBox PUEL is a binary-only version (free for personal use) which is available from the AUR or directly from the VirtualBox website. The PUEL edition offers the following advantages:

  • Remote Display Protocol (RDP) Server - a complete RDP server on top of the virtual hardware, allowing users to connect to a virtual machine remotely using any RDP compatible client
  • USB support - a virtual USB controller which allows USB 1.1 and USB 2.0 devices to be passed through to virtual machines
  • USB over RDP - a combination of the RDP server and USB support, allowing users to make USB devices available to virtual machines running remotely
  • iSCSI initiator - a builtin iSCSI initiator making it possible to use iSCSI targets as virtual disks without the guest requiring support for iSCSI


Install VirtualBox (OSE)

VirtualBox (OSE) is available from the standard repositories:

# pacman -S virtualbox-ose

This will select by default virtualbox-ose and virtualbox-modules packages. Once installed, a desktop entry can be located in Applications > System Tools > VirtualBox OSE

Now, add the desired username to the vboxusers group:

# gpasswd -a USERNAME vboxusers

(Note: You must logout/login in order for this change to take effect)

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

MODULES=(loop vboxdrv fuse ...)

To load the module manually, run the following in a terminal as root:

# modprobe vboxdrv

Install VirtualBox PUEL

VirtualBox PUEL is available from the AUR.

Due to license restrictions, you must download the installer from Sun's website (see links below) and place it into the same directory as the PKGBUILD:

Download the remaining files from the AUR page, run makepkg, and then as root:

# pacman -U PACKAGE-NAME.pkg.tar.gz

After installation, a desktop entry can be located in Applications > System Tools > Innotek VirtualBox

Now, add the desired username to the vboxusers group:

# gpasswd -a USERNAME vboxusers

(Note: You must logout/login in order for this change to take effect)

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

MODULES=(loop vboxdrv fuse ...)

To load the module manually, run the following in a terminal as root:

# modprobe vboxdrv

Module Rebuilds

Note that any time your kernel version changes (due to upgrade, recompile, etc.) you must also rebuild the VirtualBox kernel module by running vbox_build_module as root. This binary will be located in one of the following locations: /sbin, /bin, or /usr/bin. After rebuilding the module, don't forget to load it with: modprobe vboxdrv

Install required QT libraries

Currently, VirtualBox relies on qt3 for its graphical interface. If you require a GUI, ensure you have qt3 installed:

# pacman -S qt3


After we have installed VirtualBox on our system and added ourselves in the vboxusers group we can start configuring our system in order to make all the features of VirtualBox available to us.Create a new virtual machine using the wizard provided by the GUI and then click settings in order to edit the virtual machine settings.

Keyboard and mouse capture between the host and the guest

Ctrl-Alt Delete

Getting network in the guest machine to work

First let's get network working in the guest machine. Click the network tab. The not attached option means you'll have "Network cable unplugged or similar error in the guest computer.

Using NAT network

This is the simplest way to get network. Select NAT network and it should be ready to use. The NAT IP address on the first card is, on the second and so on...

Using host interface networking (the Arch way)

You are going to just edit these files and reboot:

  • /etc/conf.d/bridges
  • /etc/rc.conf
  • /etc/vbox/interfaces

Ready? Let's go!


bridge_br0="eth0" # Put any interfaces you need.

/etc/rc.conf (in your NETWORKING section, it must look like this):

eth0="eth0 up" # If you have more interfaces in the previous file, more lines like "if_number="if_number up" here.
br0="dhcp" # Maybe you have some static configuration... I use DHCP.
INTERFACES=(lo eth0 br0)

/etc/vbox/interfaces (you can set up more interfaces if you want. Sky is the limit!):

vbox0 your_user br0 # Be sure that your user is in the vboxusers group.

Reboot and enjoy!

NOTE: Remember to set up your virtual machine with proper network configuration.

NOTE: If you have any issue, make sure that you have the bridge-utils package installed.

Using host interface networking (generic)

This way is a bit harder, but it allows you to see the VirtualMachine as a "real" computer on your local network. You need to get bridge-utils

# pacman -S bridge-utils uml_utilities
      • EDIT by Sp1d3rmxn
You also need to have the TUN module rc.conf add "tun" (without the :quotes) to your MODULES section. For testing this out right now without rebooting :you can load the module from the command line by "modprobe tun".
Then you MUST set these permissions otherwise you'll never get VBox to init the :interface. The command is "chmod 666 /dev/net/tun" (without the quotes).
Now proceed with the rest as it's written below.
      • EDIT by Dharivs
As said by Sp1d3rmxn, we must set these permissions, but, instead of using the
command, we can set them in /etc/udev/rules.d/60-vboxdrv.rules, which will set them
on boot:
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
KERNEL=="tun", OWNER="root", GROUP="vboxusers", MODE="0660"

1. Create a new bridge with this command:

# brctl addbr br0

2. If you are not using DHCP, run ifconfig and note down the network configuration of your existing network interface (e.g. eth0), which we will need to copy to the bridge in a minute.

(NOTE: You will need this settings so make sure you don't lose them!!!!)

3. Switch your physical network adapter to "promiscuous" mode so that it will accept Ethernet frames for MAC addresses other than its own (replace eth0 with your network interface):

# ifconfig eth0 promisc 

(NOTE: You will lose network connectivity on eth0 at this point.)

4. Add your network adapter to the bridge:

# brctl addif br0 eth0

5. Transfer the network configuration previously used with your physical ethernet adapter to the new bridge. If you are using DHCP, this should work:

# dhclient br0
      • EDIT by Sp1d3rmxn

use "dhcpcd -t 30 -h yourhostname br0 &" instead of the above

      • End of edit

Otherwise, run ifconfig br0 x.x.x.x netmask x.x.x.x and use the values that you noted down previously.

6. To create a permanent host interface called vbox0 (all host interfaces created in this way must be called vbox followed by a number) and add it to the network bridge created above, use the following command:

VBoxAddIF vbox0 vboxuser br0

Replace vboxuser with the name of the user who is supposed to be able to use the new interface.

(NOTE: VboxAddIF is located in /opt/VirtualBox-VERSION OF VIRTUALBOX/VBoxAddIF)

Alternatively, you can setup VirtualBox networking through your /etc/rc.conf to enable a bridged connection.

(NOTE): If you get this errormessage (while doing VBoxAddIF vbox0 vboxuser br0): /usr/bin/VBoxAddIF: line 242: /var/run/VirtualBox/vboxnet: No such file or directory, you can create a symlink this way:

# ln -s /etc/rc.d/vboxnet /var/run/VirtualBox/vboxnet

Then run the commmand once more. Everything should now be OK.

Getting USB to work in the guest machine

(Only available in the PUEL edition)

First in order to make usb available for use to the virtual machine you must add this line to your /etc/fstab

none			/proc/bus/usb	usbfs	devgid=85,devmode=664 	0	0

85 is is the id of the group which should be allowed to access USB-devices. Change it to the id of your vboxusers group. You can get the id by running

grep vboxusers /etc/group

If you don't mind a security hole change devmode from 664 to 666.

Remount /proc/bus/usb:

mount -o remount /proc/bus/usb/

Restart Virtualbox and click the USB tab in the settings of the virtual machine and select which devices are available to your pc on boot. If you wish your virtual machine to use device that you have just plugged in (assuming the virtual machine has booted already), go to the VirtualMachine screen go to devices -> USB Devices -> and select the device you wish to plug in the virtual pc.

Installing Guest Additions

The Guest Additions make the shared folders feature available, as well as better video (not 3D) and mouse drivers. You will have mouse integration, thus no need to release the mouse after using it in the guest and one can also enable a bidirectional clipboard.

After you booted the virtual machine, go to menu Devices->Install Guest Additions... Once you've clicked it, VirtualBox loads an ISO into the current CD-ROM, so you won't see anything happen yet ;)

Then do the following as root :

# mount /media/cdrom
# sh /media/cdrom/

It 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 and what not. Ignore them. You will find rc.vboxadd and rc.vboxvfs in /etc/rc.d (it also creates /etc/rc.d/rc.local which you can delete). To have the Guest Additions loaded at boot time, just add those to the DAEMONS array in /etc/rc.conf eg.

DAEMONS=(syslog-ng network netfs crond alsa rc.vboxadd rc.vboxvfs)

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, "Devices" --> "Install Guest Additions"
Yes (when asked to download the CD image)
Mount (when asked to register and mount)

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

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

net use x: \\vboxsvr\sharename

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 Linux guest, use the following command:

mount -t vboxsf [-o OPTIONS] sharename mountpoint

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: 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).

Getting audio to work in the guest machine

In the machine settings go to the audio tab and select alsa driver.

Setting up the RAM and Video Memory for the virtual PC

You can change the default values by going to settings -> general.

Setting up CDROM for the Virtual PC

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.

Note: If no CDROM drive is detected, make sure the HAL daemon is running. To start it, run the following command as root:

# /etc/rc.d/hal start

Rebuilding vboxdrv module

For Virtualbox >= 1.6.0 use ABS for rebuild vboxdrv module or you can wait the maintainer update it :)

Converting from VMware images


  # pacman -S qemu
  $ qemu-img convert image.vmdk image.bin
  $ VBoxManage convertdd image.bin image.vdi

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