Virtual Machines With VB

This guide explains how you can run virtual machines with Sun VirtualBox 3.1.x (NOT OSE version!) on a headless blackPanther Server install.
Normally you use the VirtualBox GUI to manage your virtual machines, but a server does not have a desktop environment. Fortunately,
VirtualBox comes with a tool called VBoxHeadless that allows you to connect to the virtual machines over a remote desktop connection,
so there’s no need for the VirtualBox GUI.

I do not issue any guarantee that this will work for you!

1 Preliminary Note

I have tested this on a blackPanther Server (host system) with the IP address 192.168.0.100 where I’m logged in as a normal user
(user name administrator in this example) instead of as root.
If you only have a root account, but no normal user account, create one as follows (user administrator, group administrator)…

# groupadd administrator

  1. useradd -d /home/administrator -m -g administrator -s /bin/bash administrator

… create a password for the new user…

# passwd administrator

… and log in as that user.

2 Installing VirtualBox

To install VirtualBox 3.1.x on our blackPanther Server, we need root privileges, therefore we run

$ su

Then we install the dependencies for VirtualBox 3.1.x as follows (if not installed):

# installing wget flex gcc gcc-c++ kernel-devel kernel-headers dkms

Next we pick the right VirtualBox package from http://www.virtualbox.org/wiki/Linux_Downloads; pick the i386 or AMD64 package (depending on your architecture) for blackPanther OS . (you can find out your architecture by running , good choice the Mandriva or Redhat RPM packages)

… and download it as follows:

# wget http://download.virtualbox.org/virtualbox/3.2.8/VirtualBox-3.2-3.2.8_64453_mdv2009.1-1.i586.rpm -o /tmp/VirtualBox-3.2-3.2.8_64453_mdv2009.1-1.i586.rpm

To check package

# ls  -l  VirtualBox*.rpm
 tmp# ls -l VirtualBox*.rpm
-rw-r–r– 1 root root 42991260 2010-08-06 15:14 VirtualBox-3.2-3.2.8_64453_mdv2009.1-1.i586.rpm

tmp#


Afterwards, we install VirtualBox 3.x as follows:
# installing VirtualBox-3.2-3.2.8_64453_mdv2009.1-1.i586.rpm

Now we must add the user that will run VirtualBox (administrator in this example) to the vboxusers group:

# /usr/sbin/usermod -G vboxusers administrator

VirtualBox is now installed and ready to be used.

Type

# exit

to leave the root account and become a normal user (administrator) again.

3 Using VirtualBox On The Command Line

3.1 Creating A VM

To create a VM on the command line, we can use the VBoxManage command. See

$ VBoxManage --help

for a list of available switches and (highly recommended!) take a look at http://www.virtualbox.org/manual/UserManual.html#vboxmanage.

I will now create an blackPanther Virtual System VM with 256MB memory and a 10GB hard drive from the blackPanther Virtual System iso image (to_usage.iso example: blackPantherOS-v10.1.1-CD.iso).

The easy solutions the automated script. Download here: http://www.blackpantheros.eu/backend/scripts/create_vb_vm.sh

# cd /tmp

# wget http://www.blackpantheros.eu/backend/scripts/create_vb_vm.sh

To run the script enter following command

# sh create_vb_vm.sh /path/to/to_usage.iso

3.2 Importing An Existing VM

Let's assume you have a VM called examplevm that you want to reuse on this host.

On the old host, you should have a directory Machines/examplevm in the VirtualBox directory; Machines/examplevm should contain the examplevm.xml file.

Copy the examplevm directory (including the examplevm.xml file) to your new Machines directory (if your user name is administrator,

this is/home/administrator/.VirtualBox/Machines - the result should be /home/administrator/.VirtualBox/Machines/examplevm/examplevm.xml).

In addition to that copy the examplevm.vdi file from the old VDI directory to the new one (e.g. /home/administrator/.VirtualBox/VDI/examplevm.vdi).

Afterwards, you must register the imported VM:

$ VBoxManage registervm Machines/examplevm/examplevm.xml

3.3 Starting A VM With VBoxHeadless

Regardless of if you create a new VM or import and old one, you can start it with the command:

$ VBoxHeadless --startvm "blackPanther Virtual System"

(Replace blackPanther Virtual System with the name of your VM.)

VBoxHeadless will start the VM and a VRDP (VirtualBox Remote Desktop Protocol) server which allows you to see

the VM's output remotely on another machine.

To stop a VM, run

$ VBoxManage controlvm "blackPanther Virtual System " poweroff

To pause a VM, run

$ VBoxManage controlvm "blackPanther Virtual System " pause

To reset a VM, run

$ VBoxManage controlvm "blackPanther Virtual System " reset

To learn more about VBoxHeadless, take a look at

$ VBoxHeadless --help

and at http://www.virtualbox.org/manual/UserManual.html.

4 Connecting To A VM From A Remote Desktop

4.1 Windows XP

You can use the built-in Remote Desktop Connection utility to connect to the VM:

Type in the hostname or IP address of the host (not the guest!):

And voilà, you should be connected to the VM:

4.2 Linux

Use krdc or rdesktop to connect..

This page is a Wiki! Log in or register an account to edit.
admin

About admin