From ArchWiki
Revision as of 10:38, 31 March 2012 by GD (talk | contribs) (→‎Shared Folders as Arch Linux Guest: I missed next section, so it didn't auto mounted, I think this should be noted.)
Jump to navigation Jump to search


Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary link Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

VirtualBox is a virtual PC emulator like VMware. It is in constant development and new features are implemented all the time. e.g. version 2.2 introduced OpenGL 3D acceleration support for Linux and Solaris guests. It has a Qt GUI interface, as well as headless and SDL command line tools for managing and running virtual machines. It includes guest additions for some guest operating systems, which integrate functions of the guest and host systems, including sharing files, the clipboard, video acceleration and a “seamless” window integration mode.


Installation on host

The basic GPL-licensed VirtualBox suite can be installed with the virtualbox package, found in the official repositories. Note that this will also install virtualbox-modules, which contains the precompiled modules for the stock archlinux kernel. For custom kernels, read the section below.

In order to use the graphical interface, based on Qt (VirtualBox command), you will also need to install the qt package. This is not required for the simpler SDL-only GUI (VBoxSDL command) nor for the VBoxHeadless command.

Hosts running a custom kernel

VirtualBox works just fine with custom kernels such as Linux-ck without the need to keep any of the official ARCH kernel packages on the system. The trick to keeping pacman from bringing down the ARCH kernel packages is to install virtualbox with the virtualbox-source package, which contains the source for the virtualbox kernel modules. See FS#26721 for further explanations.

Once virtualbox-source is installed, simply generate the kernel modules for your custom kernel by running (assuming the system is booted into the custom kernel):

# vboxbuild

and load it:

# modprobe vboxdrv

Automatic re-compilation of the virtualbox modules with every kernel update

This is possible thanks to virtualbox-hookAUR from the AUR. In virtualbox-hook, the 'automatic re-compilation' functionality is done by a vbox hook on mkinitcpio after forcing to update the linux-headers package.

The hook will call the vboxbuild command to update the virtualbox modules for the version of your new kernel.

Note: If you are using this functionality it's important to look at the installation process of the linux (or any other kernel) package. vbox hook will tell you if anything goes wrong.
Note: If your custom kernel is using some non-standard mkinitcpio configuration file (ie. linux-zen is using /etc/mkinitcpio-zen.conf) you'll have to manually add vbox to the HOOKS array so it can be auto re-compiled after a kernel update.
Note: If you aren't using stock linux at all and still wanna use auto recompilation, you should remove linux-headers from SyncFirst list of /etc/pacman.conf after running 'vboxbuild'.

Basic setup

Add the desired username to the vboxusers group. Everything may work fine without this step but shared folders and possibly some other optional stuff require it to work. The new group does not automatically apply to existing sessions; the user has to log in again or start a new environment with a command like newgrp or sudo -u username -s.

# gpasswd -a username vboxusers

VirtualBox running on Linux uses its own kernel modules, including a mandatory one called vboxdrv, which must be loaded before virtual machines can run. It can be automatically loaded when Arch Linux starts up, or it can be loaded manually when necessary.

To load the VirtualBox driver at startup, edit /etc/rc.conf and add vboxdrv to the MODULES array:

MODULES=(... vboxdrv)
Note: You may need to update the kernel modules db in order to avoid 'no such file or directory' error when loading vboxdrv. Run: modprobed_db.

To load the module manually:

# modprobe vboxdrv

There is also the optional networking module

MODULES=(... vboxnetflt)

To load the module manually:

# modprobe vboxnetflt

To start the VirtualBox graphical manager:

$ VirtualBox

Guest additions disc

The virtualbox package also suggests installing virtualbox-additions on the host (Arch Linux) running VirtualBox. It is a disc image that can be used to install the guest additions onto guest systems.

Booting a live disc

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.

Arch Linux guests

Installing Arch under VirtualBox is straightforward, and additions should be installed through pacman (not through "Install Guest Additions" in VirtualBox, or a mounted ISO.) Follow these instructions after doing a basic install of the X-window system found on the Beginners' Guide.

Guest additions package

Install virtualbox-archlinux-additions.

Kernel modules

Manually load the VirtualBox modules with

# modprobe -a vboxguest vboxsf vboxvideo

Auto-start modules

To autostart these modules each time you boot, you can add the three modules above to the MODULES array in /etc/rc.conf.

MODULES=(... vboxguest vboxsf vboxvideo)

Enable VboxClient-all

The VBoxClient contain these services(/usr/bin/VBoxClient-all) (copy/paste...) :

 --clipboard        start the shared clipboard service
 --display          start the display management service
 --checkhostversion start the host version notifier service
 --seamless         start the seamless windows service

So you can Enable VBoxClient-all to start all these services.

If you are running something that launches /etc/xdg/autostart/vboxclient.desktop, such as GNOME, then you should be ready to go. If you use .xinitrc to launch things instead, you must add

VBoxClient-all &

to your .xinitrc before launching your WM.

You should now be all set, and all guest additions should work properly.

Shared Folders as Arch Linux Guest

Shared folders are managed via the VirtualBox program on the host. They may be added, auto-mounted (if not, read the next section) and made read-only from there. Creating a shared folder from the VirtualBox program in the host locates that folder in /media/sf_SHAREDFOLDERNAME. At this time an additional step is needed to have that folder created in the Arch Guest because Arch use a package for Guest Additions. To create and access this shared folder from the Arch Guest, this must also be done at the command line after installing the Guest Additions package(s) from pacman:

# groupadd vboxsf
# gpasswd -a $USER vboxsf

If you wish, a symbolic link may be made to another folder in your home directory for easy access. As an example, if a shared folder named "Dropbox" was created in the VirtualBox program on the host machine, then /media/sf_Dropbox is automatically created in the guest so this could be done:

$ ln -s /media/sf_Dropbox/* ~/dropbox

The .run script provided in the Guest Additions iso does this for you, however, Arch does not recommend using that script so this step must be done manually. The instructions for it were found here: (pastebin: [1]) .

Synchronise guest date with host

To keep sync date add the following to the guest /etc/rc.conf in DAEMONS entry:

DAEMONS=(... vbox-service ...)

You also need run this daemon in order to use auto-mounting feature of shared folders that are mentioned above.


USB subsystem is not working on the host

Sometimes the usb subsystem is not auto-detected resulting in an error, even when the user is in the vboxusers group. See this topic [2] for details.

Adding an entry in /etc/fstab should resolve this issue:

none  /proc/bus/usb  usbfs  auto,busgid=108,busmode=0775,devgid=128,devmode=664  0  0

External links