Differences between revisions 3 and 4
Revision 3 as of 2010-04-21 16:42:34
Size: 20845
Editor: VasilyValov
Comment:
Revision 4 as of 2010-04-21 16:54:48
Size: 21153
Editor: VasilyValov
Comment:
Deletions are marked like this. Additions are marked like this.
Line 77: Line 77:
 1. Add the [[Backports|Debian Backports]] repository to {{{/etc/apt/sources.list}}}.  For example: {{{  1. Добавьте [[Backports|Debian Backports]] репозиторий в файл {{{/etc/apt/sources.list}}}. Пример:
{{
Line 81: Line 82:
 1. Update the list of available packages and install the DebianPkg:etch-backports/debian-backports-keyring package: {{{  2. Обновите список доступных пакетов и установите пакет etch-backports/debian-backports-keyring:
{{{
Line 85: Line 87:
 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: {{{
 Система может спросить Вас о продолжении установки из неподписанного источника. Введите в приглашении {{{Yes}}}.
 3. Установите пакеты module-assistant,etch-backports/virtualbox-ose и etch-backports/virtualbox-ose-source.
{{{
Line 91: Line 93:
 1. Build and install a virtualbox-ose-modules-* package for your system using [[ModuleAssistant|Module-Assistant]]: {{{
4. Соберите и установите пакет virtualbox-ose-modules-* для Вашей системы используя [[ModuleAssistant|Module-Assistant]]:
{{{
Line 94: Line 98:
 1. Load the VirtualBox kernel module: {{{  5. Загрузите модуль VirtualBox:
{{{
Line 97: Line 102:
 1. Add your user account to the {{{vboxusers}}} group: {{{  6. Добавьте своего пользователя в группу {{{vboxusers}}}:
{{{
Line 100: Line 106:
 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.
 Перелогиньтесь для вступления изменений в силу.


VirtualBox OSE может быть загружен [[#Starting|started]].

Для автоматической загрузки модуля {{{vboxdrv}}} при запуске системы, отредактируйте файл {{{/etc/default/virtualbox-ose}}} и установите переменную LOAD_VBOXDRV_MODULE в 1.

Translation(s): English ?Español

(!) ?/Discussion


[ATTACH]

VirtualBox представляет собой эмулятор x86, разрабатываемый innotek (в последствии купленной Sun/Oracle), который является аналогом VMware. Версия VirtualBox Open Source Edition (OSE) является "свободной" и распространяется под лицензией GNU General Public License (GPL).

Это достаточно новый продукт, в связи с этим у него есть несколько незначительных недостатков. Однако в целом это стабильный, надёжный и очень быстрый эмулятор. Он успешно прошёл все тесты по установке с использованием "Установщика Дебиан".

Данная страница содержит несколько руководств, подсказок и трюков по настройке и использованию VirtualBox OSE.

.

Установка

Имеется пакет VirtualBox OSE 1.6.6 для Debian Lenny. Он также доступен в backports для Debian Etch. В репозитории testing лежит пакет VirtualBox OSE 3.1.4

Lenny

  1. Установите пакет virtualbox-ose и соответствующие Вашей системе модули ядра:

# aptitude install virtualbox-ose virtualbox-ose-modules-$(uname -r)
  • 2.Следуя руководству по udev перезагрузите установленные правила. (Обратите внимание на баг 509014):

# invoke-rc.d udev reload
  1. Загрузите модуль ядра для VirtualBox:

# modprobe vboxdrv
  1. Добавьте свою учётную запись пользователя у группу vboxusers:

# adduser yourusername vboxusers
  • Вам нужно заново зайти под учётной записью, чтобы изменения вступили в силу. L

VirtualBox OSE может быть запущен started.

Для загрузки модуля vboxdrv при запуске системы необходимо отредактировать файл /etc/default/virtualbox-ose и установить LOAD_VBOXDRV_MODULE to 1.

Lenny Backports

Поскольку VirtualBox OSE версии 1.6.6 является устаревшим, Вы можете использовать новую версию из lenny-backports для получения новой функциональности и ,возможно, исправлении существующих ошибок в старой версии.

  1. Пропишите нужные репозитории в файл /etc/apt/sources.list. Например:

# Backported packages for Debian Lenny
deb http://www.backports.org/debian lenny-backports main
  1. Обновите список доступных пакетов и установите пакет debian-backports-keyring :

# aptitude update
# aptitude -t lenny-backports install debian-backports-keyring
  • Если в Вашей системе ещё не установлен ключ для репозитория backports.org, система спросит Вас о продолжении установки из недоверяемого источника. Введите Yes в приглашении.

  • Установите нужные заголовки ядра для системы. Пример:

# aptitude update
# aptitude install linux-headers-2.6-$(uname -r | sed 's,.*-,,')
  1. Установите пакет lenny-backports/virtualbox-ose.

# aptitude -t lenny-backports install virtualbox-ose
  • Эта команда также установит все необходимые сопутствующие пакеты, а DKMS соберёт модули ядра для Вашей системы.

VirtualBox OSE может быть запущенаstarted.

Чтобы модули VirtualBox OSE не грузились при запуске системы, надо отредактировать файл /etc/default/virtualbox-ose и установить значение переменной LOAD_VBOXDRV_MODULE в 0.

Etch

  1. Добавьте Debian Backports репозиторий в файл /etc/apt/sources.list. Пример:

{{ # Backported packages for Debian Etch deb http://www.backports.org/debian etch-backports main }}}

  1. Обновите список доступных пакетов и установите пакет etch-backports/debian-backports-keyring:

# aptitude update
# aptitude -t etch-backports install debian-backports-keyring
  • Система может спросить Вас о продолжении установки из неподписанного источника. Введите в приглашении Yes.

  • Установите пакеты module-assistant,etch-backports/virtualbox-ose и etch-backports/virtualbox-ose-source.

# aptitude update
# aptitude -t etch-backports install module-assistant virtualbox-ose virtualbox-ose-source
  1. Соберите и установите пакет virtualbox-ose-modules-* для Вашей системы используя Module-Assistant:

# m-a a-i virtualbox-ose-source
  1. Загрузите модуль VirtualBox:

# modprobe vboxdrv
  1. Добавьте своего пользователя в группу vboxusers:

# adduser yourusername vboxusers
  • Перелогиньтесь для вступления изменений в силу.

VirtualBox OSE может быть загружен started.

Для автоматической загрузки модуля vboxdrv при запуске системы, отредактируйте файл /etc/default/virtualbox-ose и установите переменную LOAD_VBOXDRV_MODULE в 1.

Squeeze

  1. Update the list of available packages. Install the relevant linux-headers and virtualbox-ose packages:

    # aptitude update
    # aptitude install linux-headers-2.6-$(uname -r | sed 's,.*-,,') virtualbox-ose

    This will also install virtualbox-ose-dkms and other recommended packages. DKMS will build the VirtualBox OSE modules for your system.

VirtualBox OSE can now be started.

To not load the VirtualBox OSE modules at system startup, edit /etc/default/virtualbox-ose and set LOAD_VBOXDRV_MODULE to 0.

Starting

Desktop

  • 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
    
    Or
    
    $ VirtualBox

Server

You can start VirtualBox in Headless mode using VBoxHeadless like this:

$ VBoxHeadless -startvm "VMName"

You should run this inside a screen instance and detach the screen after starting the VM with Ctrl+a d.

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

  • $ su
    # modprobe vboxdrv

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:

  • 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 adduser(8), as described in 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 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:

  • $ 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

32-bit userland with amd64 kernel

VirtualBox does not work in such scenarios, see Debian bug 456391.

-1909 VERR VM DRIVER NOT ACCESSIBLE

[ATTACH]

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:

  • Message error:
    Failed to open/create the internal network 'HostInterfaceNetworking-br-x' (VERR_SUPDRV_INTERFACE_NOT_SUPPORTED).
    Unknown error creating VM (VERR_SUPDRV_INTERFACE_NOT_SUPPORTED).

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:

  • Could not find VirtualBox installation. Please reinstall.

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

  • # VirtualBox installation directory
    INSTALL_DIR="/usr/lib/virtualbox"

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:

  • statically (before VirtualBox is even started)

  • on demand (when a VM is being started)

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:

  • Attached to: Host Interface

  • Interface Name: vbox0

  • Setup Application: <empty>

  • Terminate Application: <empty>

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:

  • Attached to: Host Interface

  • Interface Name: <empty>

  • Setup Application: ~/.VirtualBox/bridge_setup up

  • Terminate Application: ~/.VirtualBox/bridge_setup down

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:

  • log onto your remote box
  • install tightvncserver

  • launch it (you don't need a display), pick a password
  • determine which port it is using, a way to do so:
    • netstat -tap | grep vnc

    • Let's say it's 5901
  • unlog from there since the server forked in the background

Local:

  • install xtightvncviewer

  • create a ssh tunnel to your box:
    • ssh -L 5901:localhost:5901 you@remote

  • use it: (note there are two colons)
    • xtightvncviewer localhost::5901

  • then VBoxManage startvm $yourvm &

  • and start as many virtual machines as wanted.

See Also


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


CategoryPermalink