PDA

View Full Version : CentOS 5.2 Domu on Ubuntu Hardy Dom0


Camran
11th September 2008, 11:26
Hi,

I have hard time to do it searching on the web and ... and i though it may help others to do it easier, that's why i would like to share it:
this howto may help to complete the this howto: http://www.howtoforge.com/ubuntu-8.04-server-install-xen-from-ubuntu-repositories

Create CentOS 5.2 Domu on Ubuntu Hardy Dom0

Author: Cameron Sarkary <ksarkary [at] gmail [dot] com>
Last edited 09/09/2008


This tutorial provides step-by-step instructions on how to install Images of xen on an Ubuntu Hardy Heron (Ubuntu 8.04) server system (i386).
Linux distributions that can run as Xen guests out of the box, obviating the need to create your own custom filesystems. The filesystems on jailtime.org have already been tweaked to deal with Xen’s idiosyncracies, and are also designed to be lightweight and minimally divergent from the original distribution.


This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

I will use Ubuntu Hardy Heron (i386) for the host OS (dom0) and CentOS 5.2 for the guest operating systems (domU).


This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!



1. Download the CentOS 5.1 image from jailtime.
http://jailtime.org/download:centos:v5.2

2. Untar the image:
tar -xjf centos.5-2.20080708.img.tar.bz23. Create directories under /mnt to mount image your downloaded from jailtime and in our case lvm parition.


# mkdir /mnt/img
# mkdir /mnt/vm1
4. Prepare file-based image (note: this is a meager setup of 1GB root / and 128MB swap, you'll likely want much more for a real-world VM)
# mkdir -p /home/xen/domains/centos
# cd /home/xen/domains/centos
# dd if=/dev/zero of=Cent_base.img bs=1024k count=1024
# dd if=/dev/zero of=Cent_swap.img bs=1024k count=128
# mkfs.ext3 diskimage
# mkswap swapimage
5.Mount jailtime image and lvm partition image.

# mount -o loop centos.5-2.img /mnt/img
# mount -o loop /home/xen/domains/centos/Cent_base.img /mnt/vm1
6.Copy the image files to our VM image i.e on lvm parition.

# cp -a /mnt/img/* /mnt/vm1/
7.Configure IP for domU. I don’t think I need to explain this step.

cat /mnt/vm1/etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.2548. Configure domU hostname.

[root@xen~]# cat /mnt/vm1/etc/sysconfig/networkNETWORKING=yes
HOSTNAME=complay 9. For me the xm console never worked until I have used this line in /mnt/vm/etc/inittab, I hope you know where to put following line in /mnt/vm1/etc/inittab, other wise learn about inittab first please.1:2345:respawn:/sbin/mingetty console10.root logins are not allowed on default jailtime image, so if you need them you can enable them too, or if you change your SSH port to something unusual you can do that too in /mnt/vm/etc/ssh/sshd_config change following:

Port 2023
PermitRootLogin yes11. <img id="ytte" alt="">Unmount both images.

# umount /mnt/img /mnt/vm12. My domU config file looks like following:
[root@xen]# cat centos.cfg

name = 'cent5'


kernel = '/boot/vmlinuz-2.6.24-16-xen'
ramdisk = '/boot/initrd.img-2.6.24-16-xen'
memory = '128'


root = '/dev/sda1 ro'

disk = [ 'tap:aio:/home/xen/mnt/cent_base.img,sda1,w', 'tap:aio:/home/xen/mnt/cent_swap.img,sda2,w' ]


dhcp = 'dhcp'
vif = [ '' ]


on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
13. Start your domU

# xm create -c /etc/xen/centos.cfg14. You will see a nice login prompt like following:
CentOS release 5.2 (Final)
Kernel 2.6.24-16-xen on an i686

localhost login:15.Login as root, default root password for jailtime image is “password”

16.Change your root password first http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif

17.Enter nameservers in /etc/resolv.conf

18. If you want to resize an image file.

First, make sure that the image file is not already mounted and is not already running as a xen guest. The following commands increase an image file to 4GB. Backup the image before attempting this.



dd if=/dev/zero of=/home/xen/domains/centos/Cent_base.img bs=1M conv=notrunc count=1 seek=4000
losetup /dev/loop0 /home/xen/domains/centos/Cent_base.img
e2fsck -f /dev/loop0
resize2fs /dev/loop0
e2fsck -f /dev/loop0
losetup -d /dev/loop0

You may then boot or mount the image to confirm the increased size. The e2fsck checks in this howto are not strictly necessary.

Links




http://jailtime.org/

falko
12th September 2008, 17:15
Thanks a lot! Do you mind if I publish this on the main HowtoForge site? :)

Camran
12th September 2008, 22:19
you can do it,

Thanks

laksh
29th October 2009, 06:10
hi

Need help in connecting to centos domU using vnc. please reply.

-laksh

falko
30th October 2009, 18:33
Is VNC enabled in your xend-config.sxp?

laksh
3rd November 2009, 10:57
Hi

I wan to run xen guest on nfs server please let me know how to do that.