Search:  
Gentoo Wiki

HOWTO:_VirtualBox-bin

It has been suggested that this article or section be merged into VirtualBox. (Discuss)

Contents

Binary Distribution Virtualbox-bin

To allow you to "run" the virtual machine remotely on some thin client using the Remote Desktop Protocol (RDP) we need to use the binary distribution of VirtualBox instead of OSE.

~ # USE="additions" emerge -av virtualbox-bin
    Calculating dependencies... done!
    [ebuild  N    ] x11-proto/recordproto-1.13.2  39 kB
    [ebuild  N    ] app-emulation/virtualbox-modules-1.5.2-r1  0 kB
    [ebuild  N    ] x11-libs/libXtst-1.0.3  USE="-debug" 220 kB     ;libXtst should be emerge with USE="X"
    [ebuild     U ] x11-libs/qt-3.3.8-r4 [3.3.6-r4] USE="cups doc examples mysql odbc postgres -debug -firebird -gif -immqt -immqt-bc -ipv6 -nas -nis -opengl -sqlite -xinerama" 16,986 kB
    [ebuild     U ] dev-db/qt-unixODBC-3.3.8 [3.3.6] 0 kB
    [ebuild  N    ] app-emulation/virtualbox-bin-1.5.2-r1  USE="additions -sdk" 15,573 kB


Kernel Module Vboxdrv

Virtualbox-modules contains the necessary kernel module(vboxdrv). Remember to re-emerge virtualbox-modules each time you do a kernel-upgrade (sys-kernel/module-rebuild can do it for you):

~ # emerge -av virtualbox-modules
~ # modprobe vboxdrv
~ # echo vboxdrv >> /etc/modules.autoload.d/kernel-2.6

Bridge Networking with TAP interface

Bridge-utils

For bridging support emerge bridge-utils:

~ # emerge net-misc/bridge-utils

Kernel Module

You should enable bridging support and tun/tap in kernel (or compile them as modules):

Linux Kernel Configuration: 802.1d Support
Networking --->
    Networking Options --->
    <M> 802.1d Ethernet Bridging
Device Drivers  --->
    Network device support  --->
    <M> Universal TUN/TAP device driver support

Insert these kernel modules:

~ # modprobe bridge
~ # modprobe tun

Setting br0

Configure a virtual switch br0:

~ # nano -w /etc/conf.d/net 

    ###
    ##      eth0 = Local    (Connected to the Switch)
    #
    config_eth0=( "null" )

    ###
    ##      eth1 = ADSL     (Connected to the DSL Modem)
    #
    config_eth1=( "null" )

    ###
    ##    tap0 = Virtualbox Interface (Connected to Windows XPPro)
    #
    tuntap_tap0="tap"
    config_tap0=( "null")
    
    ## For a txqueuelen problem with tap device
    ## Pls confer a Bug Report 
    ## http://bugs.gentoo.org/show_bug.cgi?id=171356
    postup() {  
        if [ ${IFACE} = tap0 ] ; then
            /sbin/ip link set ${IFACE} txqueuelen 500
        fi
    }
    
    ###
    ##      br0 = Bridging    (Virtual Switch for eth0 and tap0)
    #
    bridge_add_eth0="br0"
    bridge_add_tap0="br0"
    config_br0=( "172.17.0.100/24" )
    
    ###
    ##      PPPOE   (ADSL)  (=eth1)
    #
    config_ppp0=( "ppp" )
    link_ppp0="eth1"            
    plugins_ppp0=( "pppoe" )
    username_ppp0='xxxxxxxxxx'
    password_ppp0='xxxxxxxxx'
    pppd_ppp0=( "defaultroute" )
    

If net.eth0 and net.tap0 starts, the br0 interface comes dynamically up.

 ~ # ln -sf /etc/init.d/net.lo /etc/init.d/net.eth0
 ~ # ln -sf /etc/init.d/net.lo /etc/init.d/net.tap0
 ~ # ln -sf /etc/init.d/net.lo /etc/init.d/net.ppp0
 ~ # rc-update add net.eth0 default
 ~ # rc-update add net.tap0 default
 ~ # rc-update add net.ppp0 default
 ~ # /etc/init.d/net.eth0 restart
 ~ # /etc/init.d/net.tap0 restart
 ~ # /etc/init.d/net.ppp0 restart

Shorewall

Define network interfaces:

~ # nano -w /etc/shorewall/interfaces

    loc     eth0            -
    loc     tun0            10.0.0.255  #openvpn
    loc     tap0            -
    loc     br0             172.17.0.255    routeback
    wan     eth1            -
    net     ppp0            -

Set masquerading:

~ # nano -w /etc/shorewall/masq

    ppp0                    br0

Windows-XP Installation

Place a bootable Windows-XP install CD in CD-ROM.

Creating a Soft Link for CD-Rom

And create a soft link for CD-Rom.
  # ls -l /dev/cdrom*
    lrwxrwxrwx 1 root root  3 2008-04-02 20:25 /dev/cdrom4 -> hdc
  # ln -sf /dev/cdrom4 /dev/cdrom
  # ls -l /dev/cdrom*
    lrwxrwxrwx 1 root root 11 2008-04-02 20:36 /dev/cdrom -> /dev/cdrom4
    lrwxrwxrwx 1 root root  3 2008-04-02 20:25 /dev/cdrom4 -> hdc

VBoxManage

Check a soft link /usr/bin/VBoxManage to /opt/VirtualBox/VBox.sh:

~ # ls -l /usr/bin/VBoxManage
    lrwxrwxrwx 1 root root 23 2008-03-12 16:49 /usr/bin/VBoxManage -> /opt/VirtualBox/VBox.sh

Preparing Virtual Windows-XP

~ # VBoxManage --help
~ # VBoxManage createvm -register -name XPPro
~ # VBoxManage createvdi -size 15000MB -filename XPPro.vdi  -register
~ # VBoxManage modifyvm XPPro -name XPPro -memory 1024M -acpi on -hda XPPro.vdi -dvd host:/dev/cdrom -hostifdev1 tap0 -nic1 hostif -vrdp on
~ # VBoxManage showvminfo XPPro
~ # VBoxManage modifyvm XPPro -boot1 dvd -boot2 disk
~ # VBoxManage startvm XPPro -type vrdp

Installing Windows-XP

Go to a windows client and connect to the virtual machine (same IP as server, on which VirtuaBox runs) with 'Remote Desktop Connection' and install Windows-XP continuously on this connection.

Turning Virtual Windows-XP off

to reboot:

~ # VBoxManage controlvm  XPPro reset

to turn it off:

~ # VBoxManage controlvm  XPPro acpipowerbutton

to shutdown immediately:

~ # VBoxManage controlvm  XPPro poweroff

VirtualBox Start/Stop Script

Installation Directory

 ~ # ls -l /etc/vbox
 ~ # cat /etc/vbox/vbox.cfg
     INSTALL_DIR=/opt/VirtualBox

/etc/init.d/virtualbox-XPPro

#!/sbin/runscript
depend() {
        after samba net.eth0 net.tap0 dhcpd
}
start() {
        ebegin "Starting Virtualbox Windows XP Pro"
        # create a soft link for CD-Rom as /dev/cdrom
        if ! ls /dev | grep -w 'cdrom' 1>> /dev/null; then
             WINDOW_CD=`ls /dev/ | grep -e "cdrom[0-9]"`
             ln -sf /dev/${WINDOW_CD} /dev/cdrom
        fi
        # start virtualbox as root
        su - root /usr/bin/VBoxManage startvm XPPro -type vrdp 1> /dev/null
        result_start=$?
        eend ${result_start}
        }
stop() {
        ebegin "Stopping Virtualbox Windows XP Pro"
        #su - root /usr/bin/VBoxManage controlvm XPPro acpipowerbutton 1> /dev/null
        su - root /usr/bin/VBoxManage controlvm XPPro poweroff 1> /dev/null
        sleep 5
        result_stop=$?
        eend ${result_stop}
        }
Retrieved from "http://www.gentoo-wiki.info/HOWTO:_VirtualBox-bin"

Last modified: Fri, 05 Sep 2008 02:15:00 +0000 Hits: 6,461