Blog
Installing and Running Xen DomU Jaunty on Dom0 Ubuntu Juanty

Installing and Running Xen DomU Jaunty on Dom0 Ubuntu Juanty

Distribution: Ubuntu Jaunty 9.04

If you don't already have a Jaunty Dom0 running, follow the steps outlined in http://www.infohit.net/blog/post/running-xen-on-ubuntu-intrepid-and-jaunty.html for a method for getting a Dom0 Jaunty installation running without compiling a kernel. This tutorial assumes that you are running the Debian Xen kernel described in that post.

Create a template for Ubuntu Jaunty based on Debian Edgy

xen-create-image heavily uses templates and hooks to create images. The fastest way to create a new configuration for Xen Tools to be able to create Jaunty images is to use a configuration thats already pretty close. In this case its the Debian Edgy template. You can create a symbolic link from the edgy configuration to the jaunty one as follows:

cd /usr/lib/xen-tools
sudo ln -s edgy.d jaunty.d

Edit the Xen tools configuration

xen-tools.conf is the main configuration file containing the defaults for most of the xen-tools. We need to update it so that used the defaults most appropriate to the Debian Xen kernel installed in the first step. Update the file using gksu gedit /etc/xen-tools/xen-tools.conf

and include the settings as follows.

##
# /etc/xen-tools/xen-tools.conf
#
#
# This is the global configuration file for the scripts included
# within the xen-tools package.
#
# For more details please see:
#
# http://xen-tools.org/
#
##
dir = /workarea/xen
install-method = debootstrap
size = 4Gb # Disk image size.
memory = 128Mb # Memory size
swap = 128Mb # Swap size
fs = ext3 # use the EXT3 filesystem for the disk image.
dist = jaunty # Default distribution to install.
image = sparse # Specify sparse vs. full disk images.
dhcp = 1
kernel = /boot/vmlinuz-`uname -r`
initrd = /boot/initrd.img-`uname -r`
mirror = http://ftp.us.debian.org/debian/

ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiser_options = defaults

serial_device = hvc0
disk_device = xvda

Ensuring a getty on /dev/hvc0

Newer Xen kernels like the one used in this example use /dev/hvc0 as the console. When xen-create-image is executed, it usually creates the settings required for a getty (a login) on the Xen console. The version included in the current based distribution of Xen Jaunty includes the configuration for slightly older kernels which used a different specification for the console, therefore you need to update the file /usr/lib/xen-tools/jaunty.d/30-disable-gettys as follows. Again you can use the command: gksu gedit /usr/lib/xen-tools/jaunty.d/30-disable-gettys

and include the settings:

#!/bin/sh
#
# This script comments out all virtual terminals which aren't on the
# first console - that must remain so that 'xm console ...' works
# correctly.
#


prefix=$1


#
# Source our common functions
#
if [ -e /usr/lib/xen-tools/common.sh ]; then
. /usr/lib/xen-tools/common.sh
else
. ./hooks/common.sh
fi


#
# Log our start
#
logMessage Script $0 starting

#
# Remove the links for upstart
#
rm ${prefix}/etc/event.d/tty[!1]
cat ${prefix}/etc/event.d/tty1 | sed "s/tty1/hvc0/" > ${prefix}/etc/event.d/hvc0

#
# Are we using an alternative serial device?
#
if [ ! -z "${serial_device}" ]; then

serial_device=`basename ${serial_device}`

# Let the user know.
logMessage "Replacing default serial device (tty1) with ${serial_device}"

# replace existing device.

sed -i -e s/tty1/${serial_device}/ ${prefix}/etc/inittab

# make sure that it is allowed to login.
echo $serial_device >> ${prefix}/etc/securetty
fi


#
# Log our finish
#
logMessage Script $0 finished

Creating a template for the partitions

The directory /etc/xen-tools/partitions.d/ contains templates for layouts of the virtual disk partitions, below is a example of a suitable on for use the the Jaunty installation. Again, you can create this with gksu gedit /etc/xen-tools/partitions.d/with-data

And fill as follows:

[root]
size=4G
type=ext3
mountpoint=/
options=sync,errors=remount-ro

[swap]
size=512M
type=swap

[data]
size=4G
type=ext3
mountpoint=/data
options=nodev

Creating the new domain

Once you have the files set up you can then issue a command like (all one line):

sudo xen-create-image --hostname=mydomU --dhcp --dist=jaunty 
--mirror=http://archive.ubuntu.com/ubuntu --size=4Gb
--memory=512Mb --swap=512MB --arch=i386 --partitions=with-data
--boot --passwd --role udev

Create a root password when asked. With this command the domain will boot automatically once its been created, so you connect to it as usual with

xm console mydomU

Final Setup

xen-create-image creates an extremely basic image, after logging in to the image for the first time as root you will have a little bit of setup to do. Some examples of installations you might want to try:

  • Ubuntu Desktop: apt-get install ubuntu-desktop linux-image-virtual lvm2 user-setup
  • LAMP Server apt-get install samba apache2 php5 mysql-server lvm2 phpmyadmin user-setup
  • Semantic Mediawiki apt-get install samba apache2 php5 mysql-server lvm2 phpmyadmin user-setup mediawiki-semediawiki imagemagick
  • Java Application Server apt-get install samba apache2 php5 mysql-server lvm2 phpmyadmin user-setup sun-java5-jdk tomcat5.5 <dl><dd> </dd></dl>

After installation, don't forget to run user-setup to create your username you should usually log in as

Final Tuning

You can also configure your Xen image to use a virtual frame-buffer which you can access using VNC. To activate this add the following line to your configuration file in /etc/xen/mydomU.cfg

vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncunused=1' ] 

If you would like also to access X11 via VNC through the virtual frame-buffer, within your image, update the file /etc/X11/xorg.conf as follows (then restart X11)

Section "Device"
Identifier "Para virtual Framebuffer"
Driver "fbdev"
Option "fbdev" "/dev/fb0"
EndSection

Section "Monitor"
Identifier "Generic Monitor"
EndSection

Section "Screen"
Identifier "Default Screen"
Device "Para virtual Framebuffer"
Monitor "Generic Monitor"
EndSection

Section "InputDevice"
Identifier "Xen Mouse"
Driver "mouse"
Option "Protocol" "PS/2"
Option "Device" "/dev/input/mouse0"
EndSection


Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Xen Mouse"
EndSection

Note: You may want to install NX rather than use this method, since, while its more complex, its rather more secure. You can find details of how to set up NX here: https://help.ubuntu.com/community/FreeNX

References

Further Reading

Posted By: admin on Jun 08, 2009 05:47AM Category:Ubuntu Add Comment

Hi,
I have problem when using sudo xm console mydomU.
I can remote to domU but after 1-2 hours the terminal stops working.
Tran

Posted By: Tran on Aug 14, 2009 02:34AM

I am getting following error when I try to start my domU

xm create nishuU.cfg
Using config file "./nishuU.cfg".
Error: (38, 'Function not implemented')

Posted By: Anonymous on Oct 15, 2009 11:56AM

Everything went fine I had been able to install Dom0 Xen with the above method with a change that my IP is static not with DHCP so had to edit the /etc/resolv.conf
but then I am not clear how does debootstrap connects to the gateway since it is when I tried to create a DomU image it gave me an error since my gateway is 192.168.1.250 and this information how is Xen using I am not clear with the script

Posted By: Tapas on Nov 16, 2009 04:00AM

We're trying to configure an installation of jaunt in
/workarea/xen - but there is no hook directory for us to use.

This means we don't know how to configure this installation.

Posted By: Tapas on Nov 16, 2009 04:19AM

I am also getting the same error in fact when ever I execute xm console mydomU I get an error
mydomU does not exist

Posted By: Tapas on Nov 16, 2009 05:49AM