Join us at engage.eucalyptus.com
This is very rough but it worked for me. If there are things that you see can be easier I'd really like to know
Turns out Eucalyptus expects the --disk-image file to be a partition with
/root on it for the ssh key injection (add_key.sh) at instance startup.
You must be able to do a "mount -o loop /my/disk.img /mnt", otherwise the
add_key.sh step will fail. There weren't any docs that described it from
beginning to end so I thought I'd post all my findings here and hopefully
someone may find this of use.
I performed the following on a CentOS 5.2 host I have xen installed on
{{{
mkdir /scratch/xentmpl
cd /scratch/xentmpl
dd if=/dev/zero of=centos-root.img bs=1M count=2048
dd if=/dev/zero of=centos-swap.img bs=1M count=256
mkfs.ext3 centos-root.img
mkswap centos-swap.img
mkdir rootdisk
mount -o loop centos-root.img /scratch/xentmpl/rootdisk
cd rootdisk
mkdir dev
mkdir etc
vi etc/fstab (then drop in)
/dev/sda1 / ext3 defaults 1 1
/dev/sda2 swap swap defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
for i in console null zero; do /sbin/MAKEDEV -d /scratch/xentmpl/rootdisk/dev -x $i; done
mkdir -p lib/modules
cp -a /lib/modules/2.6.18-92.1.13.el5xen/ /scratch/xentmpl/rootdisk/lib/modules/
mkdir -p etc/sysconfig/network-scripts
vi etc/sysconfig/network-scripts/ifcfg-eth0 (then drop in)
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
vi etc/sysconfig/network-scripts/ifcfg-eth1 (then drop in)
DEVICE=eth1
BOOTPROTO=dhcp
ONBOOT=yes
vi etc/sysconfig/network (then drop in)
NETWORKING=yes
HOSTNAME=eucatmpl
GATEWAY=x.x.x.x
mkdir -p var/lock/rpm
cp /etc/yum.conf /scratch/xentmpl/
}}}
My yum.conf looks like, make sure you turn off gpgcheck
{{{
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=0
plugins=1
# Note yum-RHN-plugin doesn't honor this.
metadata_expire=1h
# Default.
# installonly_limit = 3
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
[base]
name=CentOS-5.2 - Base
baseurl=http//mirror.centos.org/centos/5.2/os/i386/
enabled=1
[extras]
name=CentOS-5.2 - Extras
baseurl=http//mirror.centos.org/centos/5.2/extras/i386/
enabled=1
#released updates
[updates]
name=CentOS-5.2 - Updates
baseurl=http//mirror.centos.org/centos/5.2/updates/i386/
enabled=1
[addons]
name=CentOS-5.2 - Addons
baseurl=http//mirror.centos.org/centos/5.2/addons/i386/
enabled=1
cd /scratch/xentmpl
yum -c yum.conf --installroot=/scratch/xentmpl/rootdisk -y groupinstall Base
yum -c yum.conf --installroot=/scratch/xentmpl/rootdisk -y install openssh openssh-server
mv rootdisk/lib/tls rootdisk/lib/tls.disabled
vi /etc/rc.d/rc.local (then drop in)
# Send 2 ping packets to frontnode
# If you are using Eucalyptus built in DHCP, skip this
ping -c 2 x.x.x.x
cd ~
umount /scratch/xentmpl/rootdisk
mkinitrd --omit-scsi-modules --with=xennet --with=xenblk --preload=xenblk /scratch/xentmpl/initrd-`uname -r`U.img `uname -r`
vi /etc/xen/centos52 (then drop in)
# This is just to test that the image boots up successfully
# NOTE the xenbr2, change it to what you bridge is coming up as
# and the , '' denotes a second interface
kernel = "/boot/vmlinuz-2.6.18-92.1.13.el5xen"
ramdisk = "/scratch/xentmpl/initrd-2.6.18-92.1.13.el5xenU.img"
name = "centos52"
memory = "256"
disk = [ 'file/scratch/xentmpl/centos-root.img,sda1,w', 'file/scratch/xentmpl/centos-swap.img,sda2,w' ]
root = '/dev/sda1 ro'
vif = [ 'bridge=xenbr2', '']
vcpus=1
on_reboot = 'destroy'
on_crash = 'destroy'
/usr/sbin/xm create -c centos52
}}}
If everything boots up successfully then you can add the image to Eucalyptus
{{{
cd /scratch/xentmpl
$EUCALYPTUS/usr/sbin/euca add_image
--disk-image centos-root.img
--kernel-image /boot/vmlinuz-2.6.18-92.1.13.el5xen
--ramdisk-image initrd-2.6.18-92.1.13.el5xenU.img
--image-name centos52
}}}
That did it for me. If you want to make quick changes to your image you can do a
"mount -o loop /your/disk.img" then make edits or inject packages like the yum step
above, or you can load it up like the "xm create" way and treat it like any other
machine then when you're finished, replace the gzipped image file in your registered
and templates and remove the local cached copy on any nodes that have it, that's the
way I do it.
Your tutorial was a great help getting.
Just have a couple of things.
I believe you forgot to mention to create FS prior to mounting and adding folders
{{{
mke2fs -j /path/to/partition
}}}
I found 2 issues and would like to know if you had the same problems
1. When I start my VM, ssh doesn't work. I tried re-installing but, it tells me the package is there but at boot time it does not work. Can you share how you got it to work?
2. The node receives a valid IP from the LAN's DHCP server and I'm able to ping all nodes within the LAN. The problem comes when I try to ping an external IP (google, yahoo etc), it replies saying that the host is not reachable.
Thanks,
Geovanny
This helped me a lot! Some of the info here seems to be a bit outdated, so I ran into some trouble. But with the help of this forum and other sites I was able to piece it together.
To help out others, I created two blog entries with this info in it
http//www.jansipke.nl/creating-a-centos-xen-virtual-machine-image
http//www.jansipke.nl/using-a-xen-virtual-machine-image-with-eucalyptus
Best regards,
Jan Sipke