Archive for June 2009
Howto: Install and run Xen DomU Centos 5 on Dom0 Ubuntu Juanty using Rinse
Step 1
If you don't already have a Ubuntu 9.04 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.
Step 2
Prepare the xen-tools environment according to the steps in http://www.infohit.net/blog/post/installing-and-running-xen-domu-jaunty-on-dom0-ubuntu-juanty.html
Step 3
Use gksu gedit /etc/rinse/centos-5.packages and add the following to the bottom of the file
nss
nspr
python-iniparse
Step 4
Make a symbolic link so rinse can be found where xen-tools expects to find it.
sudo ln -fs /usr/sbin/rinse /usr/bin/rinse
Step 5
Create and boot a new image. Set the root password when asked
sudo xen-create-image --hostname=centos5 --dhcp --dist=centos-5 --install-method=rinse --size=4Gb --memory=512Mb --swap=512MB --arch=i386 --partitions=with-data --boot --passwd --role udev
Step 6
log in as root to your newly created virtual machine and update the following
yum install nano
nano -w /etc/rpm/platform (change the line from to )
yum groupinstall "X Window System
yum groupinstall "GNOME Desktop Environment"
Update /etc/inittab to runlevel 5 reboot
For more articles about Ubuntu Xen
Compiling a Xen Dom0 Kernel for Ubuntu Jaunty
Distribution: Ubuntu Jaunty 9.04
- Note: You do not need to compile your own Dom0 kernel, read this article here to see how you can get Xen working on Juanty without compiling a kernel: www.infohit.net/blog/post/running-xen-on-ubuntu-intrepid-and-jaunty.html
Configure the environment for Compiling
From the menus choose to System -> Administration -> Software Sources you will see several check boxes.
- Canonical-supported Open Source software (main)
- Community-maintained Open Source software (universe)
- Proprietary drivers for devices (restricted)
- Software restricted by copyright or legal issues (multiverse)
- Source code
you should checked all these 5 boxes then click 'Close'. You should see a box that says "The information about available software is out of date". Click on the reload button. When these boxes have gone:
/etc/apt/sources.list should contain at least these two lines:
deb http://archive.ubuntu.com/ubuntu jaunty main universe multiverse restricted
deb-src http://archive.ubuntu.com/ubuntu jaunty main universe multiverse restricted
Now you should be able to use:
apt-get install fakeroot build-essential
apt-get install crash kexec-tools makedumpfile
apt-get build-dep linux
apt-get install git-core libncurses5 libncurses5-dev
Download and Patch the Kernel
- Download Kernel from www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.29.2.tar.bz2
- Download Patches from gentoo-xen-kernel.googlecode.com/files/xen-patches-2.6.29-6.tar.bz2
- Unpack into /usr/src/ and /usr/src/xen-patch
- Apply patches with <dl><dd> cd /usr/src/linux-2.6.29.2 </dd><dd> cat ../xen-patch/* | patch -p1 </dd></dl>
- cd /usr/src
- mv linux-2.6.29.2 linux-2.6.29.2-xen
Copy in a suitable configuration
In order to create a configuration that created a bootable kernel I actually used the configuration file found in this package: linux-image-2.6.26-2-xen-686_2.6.26-15_i386.deb
You can download it from from here:
Kernel: http://packages.debian.org/lenny/i386/linux-image-2.6.26-2-xen-686/download Modules: http://packages.debian.org/lenny/i386/linux-modules-2.6.26-2-xen-686/download
and then install using
sudo dpkg -i linux-image-2.6.26-2-xen-686_2.6.26-15lenny2_i386.deb linux-modules-2.6.26-2-xen-686_2.6.26-15lenny2_i386.deb
Its actually possible to run Xen with this debian kernel, and thats the subject of another post
You can now copy in the configuration from that kernel using:
cd /usr/src/linux-2.6.29.2-xen/
cp /boot/config-2.6.26-2-xen-686 .config
Configure and Build the Kernel
cd /usr/src/linux-2.6.29.2-xen/
make menuconfig
make
make vmlinuz
make modules_install
Copy the Kernel Image and Initial Ramdisk to /boot
cd /usr/src/linux-2.6.29.2-xen/
cp arch/x86/boot/vmlinuz /boot/xen-test-vmlinuz
mkinitramfs -o /boot/initrd-test-2.6.29.2.img 2.6.29.2
Create a Suitable Entry in /boot/grub/menu.lst
title TEST Xen 3.3.0 / Ubuntu 9.04
uuid 32ce16fb-1400-4d71-bb37-c98ef140e501
kernel /xen-3.3.0.gz
module /xen-test-vmlinuz root=/dev/vga/dom0 ro console=tty0
module /initrd-test-2.6.29.2.img
Other related Ubuntu Xenarticles.
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
- Ubuntu Xen article collection on this site.