What I've been doing. Breakdown

Friday May 02, 2008

One of my tasks at the moment is to run tests on Solaris Nevada, running as a domu on a Linux dom0.

What follows is a howto for installing hvm(Hardware Virtual Machine) guests on Ubuntu Linux, 8.04 (Hardy Heron) server-64.

Now in my case this is a build of Solaris Nevada(please see here for more information on OpenSolaris), and throughout this howto I will refer to it as snv, please feel free to switch this with your own OS name (or whatever you like really).

The machine I'm using is a Sun Fire X4150 (one of the servers on which 8.10 is certified), this machine has 8 cores (2x Quadcore Xeon x64 processors), which have Intels virtualisation extensions(Intel VT). And with plenty of RAM and 4 hard drives this machine is great for running many guests.

To be able to Xen for full virtualisation (hvm) you need a processor that has the needed extensions. Either AMD-V or Intel VT, if you don't have a chip with these extensions you might take a look at using virtualbox.

Dom0 setup

During install manually assign network info for primary network card and dns servers so as to resolve the package repositories.

Install Xen (version 3.2)
sudo apt-get install ubuntu-xen-server
sudo reboot

You should now have booted the kernel with Xen extensions.

uname -a should return
Linux hostname 2.6.24-16-xen #1 SMP Thu Apr 10 14:35:03 UTC 2008 x86_64 GNU/Linux

ps -A|grep xen should return
46 ? 00:00:00 xenwatch
47 ? 00:00:00 xenbus
5264 ? 00:00:00 xenstored
5272 ? 00:00:00 xenconsoled

xm list should return
Name ID Mem VCPUs State Time(s)
Domain-0 0 7933 8 r----- 24.0

Great, were all set to get started.

vi /etc/modules
change loop to
[...]
loop max_loop=64
[...]

####### Not exactly needed ########
One of the handy tools available on Solaris is mkfile, which you can use to create a file of whichever size. The closest Linux has to this is dd, which is a bit more ugly. However if you want to keep using dd, then by all means do.

So below is a simple zsh script which give you a nicer interface for creating files of specific sizes.
apt-get install zsh

save to /usr/bin/mkfile
#!/usr/bin/zsh
echo "mkfile [new_file_name] [filesize in Mb]"
dd if=/dev/zero of=$1 oflag=direct bs=1M count=$2

sudo chmod +x /usr/bin/mkfile

###################################
Create a hard drive for our Xen guest using mkfile (use dd if you prefer).
mkfile /mnt/sdb/snv.img 8000

*/mnt/sdb is the mount point of one of my systems drives, I intend to have one drive for each guest, thereby not killing performance by over using one disc.

We'll be using VNC to connect to get a screen from our guests so we install xvnc.
sudo apt-get install xvnc4viewer

Our plan is to install directly from an iso file, however there is currently a bug in Xen on 8.04 (or is it in 8.04, I don't know), which prevent us from doing that (the normal way) or even using our newly created .img file.

https://bugs.launchpad.net/ubuntu/+source/xen-3.2/+bug/211726
https://bugs.launchpad.net/ubuntu/+source/xen-3.2/+bug/211728

However below is the(a) workaround.

We mount our iso file to a loopback device (/dev/loop)
losetup /dev/loop0 /export/xen/isos/snv.i386.iso

And the same again for our .img file
losetup /dev/loop1 /mnt/sdb/snv.img

Now we create our guest(domu) configuration file, this is what Xen will use when the guest is created.
add below to /etc/xen/snv

kernel = "/usr/lib/xen/boot/hvmloader"
builder = 'hvm'
memory = 1024
name = "snv"
vcpus = 1
vif = [ 'type=ioemu, bridge=xenbr0' ]
disk = [ 'phy:/dev/loop1,ioemu:hda,w','phy:/dev/loop0,hdc:cdrom,r' ]
device_model = '/usr/lib/xen/bin/qemu-dm'
cdrom='/dev/hda'
ne2000=0
sdl=0
vnc=1
boot='d'

We then use xm to create our newly configured DomU

xm create snv

We now want to connect to our newly created guest and finish the install process, we do this with vnc.
vncviewer localhost

If your lucky, and have had no errors up to this point a window with the install screen should pop up.
Once you've finished the install you'll want your guest to boot off the .img file with the newly installed OS instead of the install cd/iso.

First shutdown your guest
xm shutdown snv

Edit your /etc/xen/snv file
change boot='d' boot='c' (were telling Xen to boot from drive c, instead of drive d)

Now start up your domu
xm create snv

Reconnect to your guest with vncviewer, and you should, if your lucky, be booting into your guest OS.

This is full virtualisation, as far as the OS your install is concerned, it's being installed on a real PC.

Well it seems that although the install process was easy, actually going about and using Netbeans, Java, and GlassFish from the Ubuntu package repositories wasn't quite so.

As pointed out in one of the comments in the last post the versions available as Ubuntu packages are fairly old. So I had to go ahead, download & install the latest versions anyway.