View Single Post
Old 11th September 2008, 12:26
Camran Camran is offline
Join Date: May 2008
Posts: 30
Thanks: 2
Thanked 3 Times in 3 Posts
Default CentOS 5.2 Domu on Ubuntu Hardy Dom0


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:

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 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.

2. Untar the image:
tar -xjf  centos.5-2.20080708.img.tar.bz2
3. 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

8. Configure domU hostname.

[root@xen~]# cat /mnt/vm1/etc/sysconfig/network
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 console
10.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 yes
11. <img id="ytte" alt="">Unmount both images.

# umount /mnt/img /mnt/vm
12. 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.cfg
14. 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

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.


Last edited by Camran; 11th September 2008 at 12:44.
Reply With Quote
Sponsored Links