Differences between revisions 45 and 46
Revision 45 as of 2009-06-20 06:13:27
Size: 13511
Editor: KenyonRalph
Comment: fix typo
Revision 46 as of 2009-06-22 10:24:43
Size: 17457
Editor: GeoffSimmons
Comment: Revise installation procedures, amend errors/troubleshooting, formatting. Add links, ToDo.
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
||<tablewidth="100%"style="border: 0px hidden ;">~-Translation(s): [[Spanish/VirtualBox|Español]]-~ ||<style="border: 0px hidden ; text-align: right;"> (!) [[/Discussion]] || ||<tablewidth="100%"style="border: 0px hidden ;">~-Translation(s): [[Spanish/VirtualBox|Espanol]]-~ ||<style="border: 0px hidden ; text-align: right;"> (!) [[/Discussion]] ||
Line 5: Line 5:
||<tablewidth="100%"style="border: 0px hidden ;"> {{attachment:logo.png}} ||<style="border: 0px hidden ;">VirtualBox is an x86 emulator developed by [[http://www.virtualbox.org/wiki/innotek|innotek]] ''(bought by Sun)'' comparable to [[VMware]]. It has a version called VirtualBox Open Source Edition (OSE) which is freely available as Open Source Software under the terms of the GNU General Public License (GPL).<<BR>><<BR>>Its a relatively new program and still has some minor issues, but in general it is reliable, stable and, above all, very fast. It has been used successfully to do installation tests with Debian Installer.<<BR>><<BR>>This page contains some how-to, tips and tricks that can be useful when setting up and using VirtualBox ||


## If your page gets really long, uncomment this Table of Contents
||<tablewidth="100%"style="border: 0px hidden ;"> {{attachment:logo.png}} ||<style="border: 0px hidden ;">VirtualBox is an x86 emulator developed by [[http://www.virtualbox.org/wiki/innotek|innotek]] ''(bought by Sun)'' comparable to [[VMware]].  A version called VirtualBox Open Source Edition (OSE) is freely available as Open Source Software under the terms of the GNU General Public License (GPL).<<BR>><<BR>>It is a relatively new program and still has some minor issues, but generally is reliable, stable and above all, very fast. It has been used successfully for installation tests with Debian Installer.<<BR>><<BR>>This page contains some how-to, tips and tricks when setting up and using VirtualBox. ||
Line 10: Line 8:
Line 11: Line 10:
Line 13: Line 11:
Currently ''(2008/01/01)'', VirtualBox is not supported natively by DebianEtch, the 4.0 version of Debian. To install it, you can use different methods:

 * Using Debian/Etch's [[Backports]] repository
 * Using DebianTesting repository

VirtualBox OSE 1.6.6 is packaged for Debian [[DebianLenny|Lenny]] and available as backported packages for Debian [[DebianEtch|Etch]]. VirtualBox OSE 2.1.4 is currently packaged for [[DebianTesting|testing]].

<<Anchor(lenny)>>
=== Lenny ===
Using [[DebianEtch|Etch]]? [[#etch|Skip to the Etch section]].

/* {{{udevcontrol reload_rules}}} is not invoked at virtualbox-ose postinst as {{{/sbin/udevcontrol}}} does not exist in Lenny */
 1. Install the DebianPkg:virtualbox-ose package and appropriate kernel module package for your system: {{{
# aptitude install virtualbox-ose virtualbox-ose-modules-$(uname -r)
}}}
 1. Due to Debian bug DebianBug:509014, instruct [[DebianMan:8/udevd|udevd(8)]] to reload the installed udev rules: {{{
# invoke-rc.d udev reload
}}}
 1. Load the VirtualBox kernel module: {{{
# modprobe vboxdrv
}}}
 1. Add your user account to the {{{vboxusers}}} group: {{{
# adduser yourusername vboxusers
}}}
 Log out and log back in to your system to apply the group membership change.

VirtualBox OSE can now be [[#Starting|started]].

To load the {{{vboxdrv}}} module at system startup, edit {{{/etc/default/virtualbox-ose}}} and set LOAD_VBOXDRV_MODULE to 1.

<<Anchor(etch)>>
Line 18: Line 39:

=== Debian/Etch-backports ===
 * Configure Debian/Etch [[Backports|backports]]
 * Install these packages: DebPkg:virtualbox-ose DebPkg:virtualbox-ose-source DebPkg:linux-source DebPkg:linux-headers
 * Compile virtualbox kernel module ''(as [[root]])''
{{{
# cd /usr/src
# tar xvjf virtualbox-ose.tar.bz2
# cd modules/virtualbox-ose
# make
# make install
=== Etch ===
 1. Add the [[Backports|Debian Backports]] repository to {{{/etc/apt/sources.list}}}. For example: {{{
# Backported packages for Debian Etch
deb http://www.backports.org/debian etch-backports main
}}}
 1. Update the list of available packages and install the DebianPkg:etch-backports/debian-backports-keyring package: {{{
# aptitude update
# aptitude -t etch-backports install debian-backports-keyring
}}}
 As your system does not yet have the GnuPG archive key of the backports.org repository installed, you will be asked to confirm installation of a package from an untrusted repository. Enter {{{Yes}}} when prompted.

 1. Install the DebianPkg:module-assistant, DebianPkg:etch-backports/virtualbox-ose and DebianPkg:etch-backports/virtualbox-ose-source packages: {{{
# aptitude update
# aptitude -t etch-backports install module-assistant virtualbox-ose virtualbox-ose-source
}}}
 1. Build and install a virtualbox-ose-modules-* package for your system using [[ModuleAssistant|Module-Assistant]]: {{{
# m-a a-i virtualbox-ose-source
}}}
 1. Load the VirtualBox kernel module: {{{
Line 30: Line 59:
# lsmod | grep vbox
vboxdrv 55344 0}}}
 * Or simply use module-assistant ''(as [[root]])''
{{{
# module-assistant auto-install virtualbox-ose
}}}
 1. Add your user account to the {{{vboxusers}}} group: {{{
# adduser yourusername vboxusers
}}}
 Log out and log back in to your system to apply the group membership change.

VirtualBox OSE can now be [[#Starting|started]].

To load the {{{vboxdrv}}} module at system startup, edit {{{/etc/default/virtualbox-ose}}} and set LOAD_VBOXDRV_MODULE to 1.

<<Anchor(squeeze)>>
<<Anchor(install-testing)>>
=== Squeeze ===
 1. Update the list of available packages and install the DebianPkg:module-assistant and DebianPkg:virtualbox-ose packages: {{{
# aptitude update && aptitude install module-assistant virtualbox-ose
}}}
 1. Build and install a virtualbox-ose-modules-* package for your system using [[ModuleAssistant|Module-Assistant]]: {{{
# m-a a-i virtualbox-ose-source
}}}
 1. Load the VirtualBox kernel modules: {{{
Line 36: Line 80:
# lsmod | grep vbox
vboxdrv 55344 0
}}}
 * Start VirtualBox:
In KDE, go to menu KDE > System > VirtualBox OSE

 . ''or''
In Gnome, goto menu Gnome > Applications > System tools > VirtualBox OSE

<<Anchor(install-testing)>>

=== Debian/Lenny ===
Lenny repository contains precompiled kernel module. So you don't need to compile it like previous method. Except that, it's the same mechanism.

=== Debian/Testing (Squeeze) ===
Be careful, using testing repository could break your system [revision is need here]. Note that virtualbox need to update DebPkg:libc6 and DebPkg:linux-image-2.6

If you want to use vbox as normal user add it to vboxusers group, and make sure have net module loaded:

{{{
$ adduser user vboxusers # your user should login again
$ lsmod | grep vbox
vboxnetflt 68944 0
vboxdrv 91464 2 vboxnetflt}}}
== Experience ==
~-'''__Legend :__''' -~

 * ~- {OK} = OK -~
 * /!\ = Failed
||'''Who''' ||'''Kernel''' ||'''Disribution''' ||'''Package Version''' ||'''Status''' ||
|| -- SalokineTerata <<DateTime(2008-01-01T19:52:09Z)>> || 2.6.22-6~bpo40+1 || Debian/Etch-backports || 1.5.2-dfsg2-4~bpo40+1 || {OK} ||
== Errors ==
# modprobe vboxnetflt
}}}
 1. Add your user account to the {{{vboxusers}}} group: {{{
# adduser yourusername vboxusers
}}}
 Log out and log back in to your system to apply the group membership change.

VirtualBox OSE can now be [[#Starting|started]].

To load the {{{vboxdrv}}} and {{{vboxnetflt}}} modules at system startup, edit {{{/etc/default/virtualbox-ose}}} and set LOAD_VBOXDRV_MODULE to 1.

== Starting ==
 * In [[KDE]], go to: KDE menu > System > VirtualBox OSE
 * In [[GNOME]], go to: GNOME menu > Applications > System tools > VirtualBox OSE
 * From an X terminal: {{{
$ virtualbox
}}}

== Troubleshooting ==
=== The character device /dev/vboxdrv does not exist ===
When starting VirtualBox OSE, the following message is shown:
 . {{{
WARNING: The character device /dev/vboxdrv does not exist.
         Please install the virtualbox-ose-modules package for your kernel and
         load the module named vboxdrv into your system.

         You will not be able to start VMs until this problem is fixed.
}}}

Load the VirtualBox OSE kernel module (also load {{{vboxnetflt}}} in Debian [[DebianSqueeze|Squeeze]]):
 . {{{
$ su
# modprobe vboxdrv
}}}

If the module is not found, refer to [[#Installation|Installation]] to provide a virtualbox-ose-modules-* package to your system. To load the module(s) at system startup, edit {{{/etc/default/virtualbox-ose}}} and set LOAD_VBOXDRV_MODULE to 1.

<<Anchor(error-vboxusers)>>
=== You are not a member of the "vboxusers" group ===
As stated by VirtualBox OSE:
 . {{{
WARNING: You are not a member of the "vboxusers" group. Please add yourself
         to this group before starting VirtualBox.

         You will not be able to start VMs until this problem is fixed.
}}}

Add your user account to the vboxusers group via [[DebianMan:8/adduser|adduser(8)]], as described in [[#Installation|Installation]]:
 . {{{
$ su
# adduser yourusername vboxusers
}}}

Log out and log back in to your system to apply the group membership change.

=== /dev/vboxdrv not writable for some reason ===
As stated by VirtualBox OSE:
 . {{{
WARNING: /dev/vboxdrv not writable for some reason. If you recently added the
         current user to the vboxusers group then you have to logout and
         re-login to take the change effect.

         You will not be able to start VMs until this problem is fixed.
}}}

The following group ownership of {{{/dev/vboxdrv}}} is also assigned:
 . {{{
$ ls -l /dev/vboxdrv
crw-rw---- 1 root root 10, 58 2009-06-22 16:33 /dev/vboxdrv
}}}

This is a known issue in Lenny's VirtualBox OSE version (Debian bug DebianBug:509014). To resolve, instruct [[DebianMan:8/udevd|udevd(8)]] to load the rule defined in {{{/etc/udev/rules.d/z60_virtualbox-ose.rules}}} and reload the VirtualBox OSE kernel module:
 . {{{
$ su
# invoke-rc.d udev reload
# modprobe -r vboxdrv ; modprobe vboxdrv
# exit
}}}

The correct group ownership on {{{/dev/vboxdrv}}} should now be assigned:
 . {{{
$ ls -l /dev/vboxdrv
crw-rw---- 1 root vboxusers 10, 58 2009-06-22 16:43 /dev/vboxdrv
}}}
Line 69: Line 166:
It is know bug that VirtualBox does not work in such scenarios: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456391

However VirtualBox version 2.0 promises support for this, but it is not yet packaged in Debian.
It is a known bug that VirtualBox does not work in such scenarios, see Debian bug DebianBug:456391.
Line 76: Line 171:
__Solution: __ Add your current user in the group '''vboxusers'''.

 * Under KDE:
  * {{{K > Configuration Center > System Administration > User Management}}}
  * Select your user and edit it
  * Go to '''Groups''' page
  * Select '''vboxusers''' group and validate
 * Reconnect your session
 * Under GNOME:
  * System > Administration > Users and Groups
  * Click on "'''Manage groups'''"
  * Select the '''vboxusers''' group and click "'''Properties'''"
  * Check your username in the list and click "Ok"
  * Logout and login again
 * On the commandline
  * l'''og as user root '''either by su or sudo (su [return] - <give root password> [return] OR sudo su [return])
  * Use the following command: '''adduser <youruser> vboxusers'''
  * Logout and login again
You can verify if your are really member of this group with this command line:

{{{
# id MY_USER
uid=1000(MY_USER) gid=1000(MY_USER) groupes=1000(MY_USER),8(mail),...127(vboxusers)
}}}

=== VERR_SUPDRV_INTERFACE_NOT_SUPPORTED error which bridge network ===
With virtualbox 2.2.0 network interface bridged won't works.

{{{
See [[#error-vboxusers|You are not a member of the "vboxusers" group]] above.

=== VERR_SUPDRV_INTERFACE_NOT_SUPPORTED (bridged network) ===
With VirtualBox OSE 2.2.0, a bridged network interface may not function:
 . {{{
Line 110: Line 181:
Make sure kernel modules are from 2.2.0 and not from 2.1.4. Remove 2.1.4 drivers (actually virtualbox-ose-modules-2.6.29-1-686 package, I hope next package will be with 2.2.0 modules)

{{{
m-a ai virtualbox-ose
}}}

See http://www.virtualbox.org/ticket/3733

=== Could not find Virtualbox installation ===
The following message is displayed on the console while trying to launch virtualbox:

{{{
Ensure the installed virtualbox-ose-modules-* package matches the VirtualBox OSE version available in [[DebianTesting|testing]]. If not, build and install a new virtualbox-ose-modules-* package using [[ModuleAssistant|Module-Assistant]], refer to the [[#install-testing|Installation]] section. See also http://www.virtualbox.org/ticket/3733.

=== Could not find VirtualBox installation ===
The following message is displayed on the console while trying to launch VirtualBox:
 . {{{
Line 125: Line 189:
Create the following file under '''/etc/vbox/vbox.cfg'''

W
ith contents:
{{{
To resolve, create the {{{/etc/vbox/vbox.cfg}}} file with the following content:
 . {{{
Line 134: Line 196:

== Tips & tricks ==
== Tips & Tricks ==
Line 143: Line 204:
This is documented in the [[http://www.virtualbox.org/download/UserManual.pdf|VirtualBox user manual]] in the section "Keyboard and mouse support in virtual machines", subsection "Typing special characters". This is documented in the [[http://www.virtualbox.org/manual/UserManual.html|VirtualBox user manual]] in the section "Keyboard and mouse support in virtual machines", subsection "Typing special characters".
Line 155: Line 216:
First install the package {{{bridge-utils}}}. First install the DebianPkg:bridge-utils package.
Line 159: Line 220:
Change the file {{{/etc/network/interfaces}}} to look something like this:

{{{
Change the file {{{/etc/network/interfaces}}} to look something like this: {{{
Line 174: Line 233:
In this example the bridge gets its IP address and configuration from DHCP. For static configuration see<<BR>>{{{/usr/share/doc/bridge-utils/README.Debian.gz}}}

If you don't find the information for static configuration there, try:<<BR>>

{{{
# man bridge-utils-interfaces}}}
Restart the networking of the host system using:

{{{

In this example the bridge gets its IP address and configuration from DHCP. For static configuration information, see [[DebianMan:5/bridge-utils-interfaces|bridge-utils-interfaces(5)]] (Lenny) or {{{/usr/share/doc/bridge-utils/README.Debian.gz}}} (Etch).

Restart the networking of the host system using: {{{
Line 184: Line 238:
Line 186: Line 241:
It is also necessary for your user to own the device {{{/dev/net/tun }}}

Run the following command to change the owner of that device:

{{{
It is also necessary for your user to own the device {{{/dev/net/tun}}}.

Run the following command to change the owner of that device: {{{
Line 192: Line 245:
Line 199: Line 253:
See also the chapter on "Virtual networking" in the [[http://download.virtualbox.org/virtualbox/2.2.2/UserManual.pdf|VirtualBox user manual]].
See also the chapter on "Virtual networking" in the [[http://www.virtualbox.org/manual/UserManual.html#networkingdetails|VirtualBox user manual]].
Line 204: Line 259:
Example to create an interface for a user:

{{{
Example to create an interface for a user: {{{
Line 217: Line 270:
Line 254: Line 308:
Line 256: Line 311:
Here is a snippet of a sudoers file to help (replace username and hostname with the appropriate values):

{{{
Here is a snippet of a sudoers file to help (replace username and hostname with the appropriate values): {{{
Line 263: Line 316:
Line 271: Line 325:
=== How to remotely start virtual machines using vnc === === How to remotely start virtual machines using VNC ===
Line 275: Line 329:
 * install tightvncserver  * install DebianPkg:tightvncserver
Line 278: Line 332:
  * netstat -tap | grep vnc   * {{{netstat -tap | grep vnc}}}
Line 281: Line 335:
Line 283: Line 338:
 * install xtightvncviewer  * install DebianPkg:xtightvncviewer
Line 285: Line 340:
  * ssh -L 5901:localhost:5901 you@remote   * {{{ssh -L 5901:localhost:5901 you@remote}}}
Line 287: Line 342:
  * xtightvncviewer localhost::5901
 * then VBoxManage startvm $yourvm &
  * {{{xtightvncviewer localhost::5901}}}
 * then {{{VBoxManage startvm $yourvm &}}}
Line 290: Line 345:

== See Also ==
 * Alternative SystemVirtualization tools.
Line 291: Line 350:
 * http://download.virtualbox.org/virtualbox/2.2.2/UserManual.pdf Official User Manual
 * Alternative SystemVirtualization tools.
 * http://www.virtualbox.org/ - VirtualBox OSE homepage;
  * http://www.virtualbox.org/wiki/User_FAQ - Frequently Asked Questions
  * http://www.virtualbox.org/manual/UserManual.html ([[http://download.virtualbox.org/virtualbox/2.2.4/UserManual.pdf|PDF]]) - Official User Manual
  * [[irc://irc.freenode.net/%23vbox|#vbox]] - [[IRC]] channel
Line 294: Line 356:
ToDo: Eventually purge obsolete information from this page, including:
 * {{{/dev/net/tun}}} (see bug DebianBug:509524)
 * {{{/etc/vbox/vbox.cfg}}} (see bug DebianBug:530321)
 * {{{VBoxAddIF}}} (removed in DebianPkg:virtualbox-ose 2.1.0-dfsg-1)
 * {{{VBoxTunctl}}} (removed in DebianPkg:virtualbox-ose 2.1.0-dfsg-1)

------

Translation(s): ?Espanol

(!) ?/Discussion


logo.png

VirtualBox is an x86 emulator developed by innotek (bought by Sun) comparable to VMware. A version called VirtualBox Open Source Edition (OSE) is freely available as Open Source Software under the terms of the GNU General Public License (GPL).

It is a relatively new program and still has some minor issues, but generally is reliable, stable and above all, very fast. It has been used successfully for installation tests with Debian Installer.

This page contains some how-to, tips and tricks when setting up and using VirtualBox.

Installation

VirtualBox OSE 1.6.6 is packaged for Debian Lenny and available as backported packages for Debian Etch. VirtualBox OSE 2.1.4 is currently packaged for testing.

Lenny

Using Etch? Skip to the Etch section.

  1. Install the virtualbox-ose package and appropriate kernel module package for your system:

    # aptitude install virtualbox-ose virtualbox-ose-modules-$(uname -r)
  2. Due to Debian bug 509014, instruct udevd(8) to reload the installed udev rules:

    # invoke-rc.d udev reload
  3. Load the VirtualBox kernel module:

    # modprobe vboxdrv
  4. Add your user account to the vboxusers group:

    # adduser yourusername vboxusers
    Log out and log back in to your system to apply the group membership change.

VirtualBox OSE can now be started.

To load the vboxdrv module at system startup, edit /etc/default/virtualbox-ose and set LOAD_VBOXDRV_MODULE to 1.

Etch

  1. Add the Debian Backports repository to /etc/apt/sources.list. For example:

    # Backported packages for Debian Etch
    deb http://www.backports.org/debian etch-backports main
  2. Update the list of available packages and install the etch-backports/debian-backports-keyring package:

    # aptitude update
    # aptitude -t etch-backports install debian-backports-keyring

    As your system does not yet have the GnuPG archive key of the backports.org repository installed, you will be asked to confirm installation of a package from an untrusted repository. Enter Yes when prompted.

  3. Install the module-assistant, etch-backports/virtualbox-ose and etch-backports/virtualbox-ose-source packages:

    # aptitude update
    # aptitude -t etch-backports install module-assistant virtualbox-ose virtualbox-ose-source
  4. Build and install a virtualbox-ose-modules-* package for your system using Module-Assistant:

    # m-a a-i virtualbox-ose-source
  5. Load the VirtualBox kernel module:

    # modprobe vboxdrv
  6. Add your user account to the vboxusers group:

    # adduser yourusername vboxusers
    Log out and log back in to your system to apply the group membership change.

VirtualBox OSE can now be started.

To load the vboxdrv module at system startup, edit /etc/default/virtualbox-ose and set LOAD_VBOXDRV_MODULE to 1.

Squeeze

  1. Update the list of available packages and install the module-assistant and virtualbox-ose packages:

    # aptitude update && aptitude install module-assistant virtualbox-ose
  2. Build and install a virtualbox-ose-modules-* package for your system using Module-Assistant:

    # m-a a-i virtualbox-ose-source
  3. Load the VirtualBox kernel modules:

    # modprobe vboxdrv
    # modprobe vboxnetflt
  4. Add your user account to the vboxusers group:

    # adduser yourusername vboxusers
    Log out and log back in to your system to apply the group membership change.

VirtualBox OSE can now be started.

To load the vboxdrv and vboxnetflt modules at system startup, edit /etc/default/virtualbox-ose and set LOAD_VBOXDRV_MODULE to 1.

Starting

Troubleshooting

The character device /dev/vboxdrv does not exist

When starting VirtualBox OSE, the following message is shown:

Load the VirtualBox OSE kernel module (also load vboxnetflt in Debian Squeeze):

If the module is not found, refer to Installation to provide a virtualbox-ose-modules-* package to your system. To load the module(s) at system startup, edit /etc/default/virtualbox-ose and set LOAD_VBOXDRV_MODULE to 1.

You are not a member of the "vboxusers" group

As stated by VirtualBox OSE:

Add your user account to the vboxusers group via adduser(8), as described in Installation:

Log out and log back in to your system to apply the group membership change.

/dev/vboxdrv not writable for some reason

As stated by VirtualBox OSE:

The following group ownership of /dev/vboxdrv is also assigned:

This is a known issue in Lenny's VirtualBox OSE version (Debian bug 509014). To resolve, instruct udevd(8) to load the rule defined in /etc/udev/rules.d/z60_virtualbox-ose.rules and reload the VirtualBox OSE kernel module:

The correct group ownership on /dev/vboxdrv should now be assigned:

32-bit userland with x86_64 kernel

It is a known bug that VirtualBox does not work in such scenarios, see Debian bug 456391.

-1909 VERR VM DRIVER NOT ACCESSIBLE

error-1909-VERR_VM_DRIVER_NOT_ACCESSIBLE.png

See You are not a member of the "vboxusers" group above.

VERR_SUPDRV_INTERFACE_NOT_SUPPORTED (bridged network)

With VirtualBox OSE 2.2.0, a bridged network interface may not function:

Ensure the installed virtualbox-ose-modules-* package matches the VirtualBox OSE version available in testing. If not, build and install a new virtualbox-ose-modules-* package using Module-Assistant, refer to the Installation section. See also http://www.virtualbox.org/ticket/3733.

Could not find VirtualBox installation

The following message is displayed on the console while trying to launch VirtualBox:

To resolve, create the /etc/vbox/vbox.cfg file with the following content:

Tips & Tricks

Switching consoles

The normal way to switch consoles in Linux is to use the ctrl-alt-Fx key combination. This does not work for a VirtualBox virtual machine (VM); it will switch consoles for the host system instead.

You should use <Host Key>-Fx instead, where <Host Key> is the key defined in File->Preferences->Input.

This also works for ctrl-alt-del and ctrl-alt-backspace

This is documented in the VirtualBox user manual in the section "Keyboard and mouse support in virtual machines", subsection "Typing special characters".

(An alternative method to switch between text consoles is to use alt-left and alt-right, but that does not work for graphical consoles like XOrg or DirectFB.)

Setting up bridged networking for VirtualBox (VirtualBox < 2.1.0)

By default VirtualBox uses NAT for the network interfaces of virtual machines and use an internal DHCP server to obtain an IP address. This works well but the disadvantage is that the machine will not have an IP address visible outside the VM and so you cannot connect to it from the host system or from other systems.

By attaching the VM's interface to "Host Interface" and creating a bridge on the host system, the VM can be made visible on the local network. This also allows to do fun stuff like netbooting the VM (boot from LAN using PXE). It is comparable to the "bridged networking" option in VMWare.

NB To use a wireless host device you need one that has support for Master mode (eg. it can be used as an access point, afaik only the Atheros and Prism drivers has this support)

Preparation

First install the bridge-utils package.

Next, change the network configuration of the host system so that the network interface becomes part of a bridge. Note that this requires restarting the network, so be careful when doing this on a remote system!

Change the file /etc/network/interfaces to look something like this:

# The loopback network interface
auto lo
iface lo inet loopback
# An entry for eth0 is no longer needed
#auto eth0
#iface eth0 inet dhcp
# Create the bridge (with the regular IP address of the host)
auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_fd 2.5

In this example the bridge gets its IP address and configuration from DHCP. For static configuration information, see bridge-utils-interfaces(5) (Lenny) or /usr/share/doc/bridge-utils/README.Debian.gz (Etch).

Restart the networking of the host system using:

# /etc/init.d/networking restart

After this brctl show should show the bridge and ifconfig should show the bridge has the host's IP address.

It is also necessary for your user to own the device /dev/net/tun.

Run the following command to change the owner of that device:

# chown <username> /dev/net/tun

If you have built your own kernel/modules then ensure the host machine has the vboxnetflt driver loaded.

Configuring the VirtualBox VM

There are different ways the TAP interface for the VM can be created:

See also the chapter on "Virtual networking" in the VirtualBox user manual.

Static interfaces

In this case you only need to "define" an interface for use by a particular user once. All defined interfaces are "remembered" in the file /etc/vbox/interfaces and recreated by the VirtualBox init script every time the host system is booted.

Example to create an interface for a user:

# VBoxAddIF vbox0 <username> br0

You can of course create multiple interfaces per users, but all interfaces should have unique names.

To configure the VM to use static bridged networking, go to the "network" page of the VM's settings and change the following fields:

Dynamic interfaces (on demand)

The example below shows the second method. This example will allow you to use multiple VM's, but the script assumes that each interface will be named in the form "vbox*". You may need to adapt the script to match your needs. Note that the script assumes you can execute the needed commands using sudo. A snippet of a sudoers file is included below as an example.

set -e
BRIDGE="br0"
case "${1}" in
        "up" )
                # Get the last vbox interface that was created or "" if none
                TAP=$(cat /proc/net/dev | grep vbox | tail -n 1 | cut -d":" -f1 | sed 's/\s*vbox\(\.*\)/\1/')
                # If there was no previous interface then set to -1 (this is so the += works)
                [ "${TAP}" = "" ] && TAP=-1
                # Increment TAP
                let "TAP+=1"
                # prepend vbox onto the TAP no
                TAP="vbox${TAP}"
                # Create the new TAP device
                sudo VBoxTunctl -b -u $(whoami) -t ${TAP}
                # Bring up the TAP (without an ip)
                sudo ifconfig ${TAP} up
                # Add the TAP to the Bridge
                sudo brctl addif ${BRIDGE} ${TAP}
                # Echo the name of the TAP so VirtualBox knows which one to use
                # on lenny the echo must be commented for virtuabox to work correctly
                echo ${TAP}
                ;;
        "down" )
                # VirtualBox tells us which TAP it used
                TAP=${3}
                # Bring the TAP down
                sudo ifconfig ${TAP} down
                # Remove the TAP
                sudo VBoxTunctl -d ${TAP} > /dev/null 2>&1
                ;;
esac

Save the script, for example as ~/.VirtualBox/bridge_setup. The script can be tested by running it from the command line. If successful, brctl show should show interface vbox* (where * will be a number) added to the bridge.

Here is a snippet of a sudoers file to help (replace username and hostname with the appropriate values):

Cmnd_Alias      VIRTUALBOX = /usr/bin/VBoxTunctl, /sbin/ifconfig vbox* up, /sbin/ifconfig vbox* down, /usr/sbin/brctl addif br0 vbox*
username     ALL=(ALL) PASSWD: ALL
username     hostname = NOPASSWD: VIRTUALBOX

To configure the VM to use dynamic bridged networking, go to the "network" page of the VM's settings and change the following fields:

When the VM is started after that, the interface should be created automatically and the VM can be used just like it was a system connected directly to your local network.

How to remotely start virtual machines using VNC

Remote:

Local:

See Also


ToDo: Eventually purge obsolete information from this page, including:


CategoryPermalink