VirtualBox

VirtualBox
VirtualBox
 * "innotek VirtualBox is a family of powerful x86 virtualization products for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL)."

VirtualBox user manual

VirtualBox vs Others

RedHat
Download VirtualBox RPM (I am using the RHEL5 RPM)
 * 1) Download: VirtualBox-1.5.6_28266_rhel5-1.i586.rpm

Install dependencies: yum install gcc kernel-devel SDL alsa-lib qt libxslt yum install gcc kernel-devel SDL.x86_64 alsa-lib.x86_64 qt.x86_64 libxslt.x86_64
 * 1) i386
 * 2) yum install gcc kernel-devel libSDL-1.2.so.0 libasound.so.2 libqt-mt.so.3 libxslt.so.1
 * 1) x86_64

Install RPM: rpm -Uvh VirtualBox-1.5.6_28266_rhel5-1.i586.rpm rpm -Uvh VirtualBox-1.6.0_30421_rhel5-1.x86_64.rpm
 * 1) i386
 * 1) x86_64

Ubuntu
apt-get update ; apt-get install virtualbox

Kernel Module
These installs will attempt to compile the kernel module. If you need to rerun the setup due to a failure, run: /etc/init.d/vboxdrv setup

Comparison
VBox_vs_Others – Oracle VM VirtualBox - VirtualBox vs. VMware vs. Parallels - http://www.virtualbox.de/wiki/VBox_vs_Others

GUI
The VirtualBox GUI can create and control VMs

Command Line Tools
VBoxManage is our command-line interface (See chapter 7 of the user manual)

List VMs: VBoxManage list vms

Show VM details: vm showvminfo

Start VM: VBoxManage startvm VBoxManage startvm -type vrdp VBoxHeadless -startvm VBoxHeadless -startvm -p
 * 1) Start with RDP support
 * 1) VBoxVRDP has been renamed VBoxHeadless in v1.6

Stop VM: VBoxManage controlvm poweroff

Reset VM: VBoxManage controlvm reset

Add aliases for easy usage: vi /etc/bashrc alias vm=VBoxManage alias vmlist="vm list vms | grep Name"

Creating a virtual machine on a headless server
VirtualBox User Manual 7.4.2 Step by step: creating a virtual machine on a headless server:

Set virtualbox name: VBOXNAME="centos5"

Create Virtual Machine: VBoxManage createvm -name "$VBOXNAME" -register

Settings for VM: VBoxManage modifyvm "$VBOXNAME" -memory "256MB" -acpi on -boot1 dvd -nic1 nat

Create virtual disk (10GB): VBoxManage createvdi -filename "$VBOXNAME.vdi" -size 10000 -register VBoxManage modifyvm "$VBOXNAME" -hda "$VBOXNAME.vdi"

Attach ISO to VM: VBoxManage modifyvm "$VBOXNAME" -dvd /full/path/to/iso.iso
 * 1) VBoxManage modifyvm "$VBOXNAME" -dvd ~/CentOS-5.1-i386-bin-1of6.iso

Start VM RDP: VBoxVRDP -startvm "$VBOXNAME"

Connect via RDP to VM: rdesktop -a 16 my.host.address

Unmount ISO so reboots work: VBoxManage modifyvm "$VBOXNAME" -dvd none

Bridge Networking
Install bridge tools: yum install bridge-tools

Setup a bridge network: brctl addbr br0
 * 1) create bridge

ifconfig eth0 0.0.0.0
 * 1) remove address from eth0 (will disable networking)

brctl addif br0 eth0
 * 1) add interface to bridge

dhclient eth0 or... ifconfig br0 x.x.x.x netmask x.x.x.x
 * 1) reconnect network

VBoxAddIF vbox0 root br0
 * 1) create permenant virtual interface

VBoxDelIF vbox0
 * 1) delete virtual interface

ifconfig
 * 1) list current virtual interfaces

For a permenet bridge configuration: DEVICE=br0 TYPE=Bridge BOOTPROTO=dhcp ONBOOT=yes DEVICE=br0 TYPE=Bridge BOOTPROTO=static IPADDR=10.161.101.6 NETMASK=255.255.255.0 ONBOOT=yes
 * 1) Add bridge device
 * 2) /etc/sysconfig/network-scripts/ifcfg-br0
 * 1) the bridge will take over eth0, so set it to the static IP of eth0

BRIDGE=br0
 * 1) Add eth0 to bridge
 * 2) /etc/sysconfig/network-scripts/ifcfg-eth0

/sbin/service network restart
 * 1) Restart service

VBoxAddIF vbox0 br0 VBoxDelIF vbox0
 * 1) Create virtualbox host interface and add to bridge
 * 2) vbox0 => "all host interfaces created in this way must be called vbox followed by a number"
 * 3) => "Replace with the name of the user who is supposed to be able to use the new interface."
 * 4) To see current host interfaces see ifconfig
 * 1) Delete if needed...


 * 1) Tell VM to use virtual interface under "settings"->"network"->"attached to"
 * 2) and enter "vbox0" into the "interface name" field.

Switch VM interface to host interface mode: VBoxManage modifyvm "$VBOXNAME" -hostifdev1 vbox0
 * 1) NOTE: A VIRTUAL INTERFACE CAN ONLY BE USED WITH WITH ONE VIRTUAL MACHINE
 * 1) VBoxManage modifyvm "$VBOXNAME" -nic1 hostif