Friday, June 13, 2008

Installing VirtualBox on 7.04 Server edition for VRDP use

Jose Catre-Vandis
September 20th, 2007, 07:29 PM
Aim: to install a command line system, using the 7.04 server edition, and then to install Virtualbox on it, so that I can run VMs using VRDP and access them remotely using rdesktop on client machines.

PART I
Installing the 7.04 server edition is easy, so I'll skip that.

PART II
Installing VirtualBox is much more difficult, but I got it done in the end as follows. But what I want to know is if there is a better way to do this, e.g. install a desktop 7.04 and strip it back, or reduce all the items I had to install. Not had a chance to do extensive testing on all the variations.

If you are running a headless server, login via ssh (you may need to install openssh-server after the initial install), if not work from the command line at the PC

first off, install lots of kernel/sources stuff
###install needed linux components

sudo apt-get install linux-source
sudo apt-get install make gcc build-essential
sudo apt-get install xen-headers #[choose the version you need, in this case - 2.6.19-4-server]
sudo apt-get install xen-headers-2.6.19-4-server
sudo apt-get install linux-headers-$(uname -r)

#Bridging Utilities
If you are planning on bridging your network interface, install these two packages as well
[sudo apt-get install bridge-utils
sudo apt-get install uml-utilities[/code]


###install virtualbox (may fail at this stage)

sudo nano /etc/apt/sources.list #[add vbox repository]
deb http://www.virtualbox.org/debian feisty non-free #[add this line and save file]
wget http://virtualbox.org/debian/innotek.asc
sudo apt-key add innotek.asc
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install virtualbox

(you will be asked to install loads of dependencies as well)

###Picked this section up from virtualbox.org forums, as applied to Debian Etch - credits "Ingo"
(on a second attempt at this with a fresh server install, I did not need any of this section)

cd /usr/src
sudo adduser tim src
sudo tar -xvjf linux-source-2.6.20.tar.bz2
sudo ln -s linux-source-2.6.20 linux
sudo cp /boot/config-$(uname -r) linux/.config
cd linux
sudo make oldconfig
sudo make vmlinux
sudo make oldconfig && make prepare (optional?) if above doesn't work!

#####retry setup of virtualbox if necessary

sudo /etc/init.d/vboxdrv setup

you may need to try compile again if it doesn't work first time (credits bohdi zazen :))

and it should successfully compile and load vboxdrv.

You then need to add your username to vboxusers (you should have got a warning) :

sudo adduser username vboxusers

I also added myself to the uml-net group in the same way, due to my tap interface setup. You shouldn't need to do this if you are simply using NAT
(If you haven't installed uml-utilities this group won't be there :))
sudo adduser username uml-net

###Logout and login again (to make the new group assignments work)

and with any luck Virtualbox is installed and running. You can then install a VM from the command line, start it up, and access the VM remotely. I did a clone of an existing VM and copied it over to the server, to save time and make life easier.

PART III
Installing a VM in a headless server on the command line

(Credits to Virtualbox help for some of this!)
We'll use Windows XP as the example VM

On the headless server create the following directories:
sudo mkdir ~/.VirtualBox

(if not already there)
sudo mkdir ~/.VirtualBox/VDI

Then copy your WinXP.vdi file over

cp /path/to/your/vdi/WinXP.vdi ~/.Virtualbox/VDI

On the headless server/at the command line, create a new virtual machine:
VBoxManage createvm -name "Windows XP" -register
Create the settings (read the help file if you want alternatives)
VBoxManage modifyvm "Windows XP" -memory "256MB"-acpi on -boot1 dvd -nic1 nat

Use this as well if you are using host interface, you will need to replace "tap1" with the name of your interface!
VBoxManage modifyvm "Windows XP" -nic1 hostif
VBoxManage modifyvm "Windows XP" -hostifdev1 tap1

Add your VDI file as the first virtual hard disk of the new VM:
VBoxManage modifyvm "Windows XP" -hda "WinXP.vdi"

[INSERT]
################################################## #######
If you need to create a new vdi and carry out an OS installation, follow these steps instead of just copying a vdi file over from somewhere else:

Create a virtual hard disk for the VM (in this case, 10GB in size) and register it with VirtualBox:
VBoxManage createvdi -filename "Windows XP.vdi" -size 10000 -register
Set this newly created VDI file as the first virtual hard disk of the new VM:
VBoxManage modifyvm "Windows XP" -hda "Windows XP.vdi"
Register the ISO file that contains the operating system installation that you want to install later:
VBoxManage registerimage dvd /full/path/to/iso.iso
Attach this ISO to the virtual machine, so it can boot from it:
VBoxManage modifyvm "Windows XP" -dvd /full/path/to/iso.iso

I found I got double mouse problems during the installation, but you can get by through moving the "mice" around so that you can click in the right places!

Installing VBox Additions is a bit of a fiddle this way, but if you register the iso in the same way as for the OS iso above, and then attach it you should be good to go, but you will have to browse to the iso and run the executable. The additions iso should be found here: /usr/share/virtualbox/

#############################################
[END OF INSERT]

Start the virtual machine using VBoxVRDP:
VBoxVRDP -startvm "Windows XP"
If everything worked, you should see a copyright notice. If, instead, you are returned to the command line, then something went wrong.
On the client machine, fire up the RDP viewer and try to connect to the server. Assuming an Ubuntu client:
rdesktop -a 16 my.host.address

Advice is you should set your VM to run in 16m colours to match the rdesktop call

Tuesday, June 10, 2008

VirtualBox

Open Source Edition on Ubuntu 8.04 (Hardy)

Installing VirtualBox OSE on Hardy is even easier. From a terminal session run the following commands to install Virtualbox OSE.

sudo apt-get install virtualbox-ose virtualbox-ose-source virtualbox-ose-modules-generic

Add yourself to the vboxusers group. You can add more usernames after "whoami" if you wish.

sudo gpasswd -a `whoami` vboxusers
or
sudo usermod -Gvboxusers -a `whoami`

You will now have to log out of your desktop session and log back in order to update your group membership. Congratulations, you can now skip down to "Using Virtual Box" (which might be out of date?)

If you have a multi-core CPU and experiment high CPU usage even when the guest OS is almost no using CPU, you can force Virtual Box to execute in just one of your cores by launching it through taskset.

sudo apt-get install util-linux
taskset -c 1 virtualbox

See [WWW] http://www.virtualbox.org/ticket/1233 and [WWW] http://ubuntuforums.org/showthread.php?t=775503 for further info on this issue.

Networking Bridge Ubuntu

To start, NAT is by far the easiest way to get your guests connected to the interweb, but you may want to use the guests as servers, for this you need Host Networking. You will need to install bridge-utils and uml-utilities so that you can make a tap device and add it to a bridge.

sudo apt-get install bridge-utils uml-utilities

Now make a bridge, and put your current interface into it:

sudo tunctl -t tap1 -u fred #where fred is the user you will be running vbox as
sudo chown root.vboxusers /dev/net/tun
sudo chmod g+rw /dev/net/tun

Set the permission to persist across reboots, by editing as root /etc/udev/rules.d/20-names.rules and changing:

KERNEL=="tun",                          NAME="net/%k"

to

KERNEL=="tun",                          NAME="net/%k",  GROUP="vboxusers",     MODE="0660"

Make a new bridge called br0:

sudo brctl addbr br0

Put your current interface (in this case eth0) into promiscuous mode, then add it to the bridge and give the bridge a dhcp address.

sudo ifconfig eth0 0.0.0.0 promisc
sudo brctl addif br0 eth0

If you are using DHCP to automatically get an IP address, set the bridge to use DHCP.

sudo dhclient br0

If you are using a static IP, specify the IP address, netmask and add the default gateway route

#Where 192.168.1.105 is your static IP and 255.255.0.0 is your netmask
sudo ifconfig br0 192.168.1.105 netmask 255.255.0.0

#Where 192.168.1.1 is your default gateway
sudo route add default gw 192.168.1.1 br0

Add the new tap1 device to the bridge and activate tap1 (the second line appears to be necessary according to [WWW] http://ubuntuforums.org/showthread.php?t=561461#3)

sudo brctl addif br0 tap1
sudo ifconfig tap1 up

You should now be able to use host networking in vbox, just change "attached to" to "host interface" and add the interface name of tap1 in your networking settings. Read the manual as well, there are some other nifty ways to do this. Do not forget to use the root account when doing this. Also reboot your computer afterwords.

Mobile Device Deployment - CISSP (Domain 3)

Mobile Device Deployment Policies Mobile Device Deployment Policy harus diarahkan secara luas terkait penggunaan perangkat yang diizinkan da...