[CentOS] Amazon EC2 - building a minimal centOS ebs bootable image

Sat Jan 29 14:16:12 UTC 2011
Rainer Traut <tr.ml at gmx.de>

Am 29.01.2011 09:36, schrieb Sanjay Arora:
> Looking to build CentOS based micro EC2 instance bootable from Amazon
> EBS. Want that the image be minimal, so that I can add only the rpms I
> want.
>
> Despite looking could not find a way to import a CentOS image from
> scratch or an existing minimal CentOS image that is bootable from EBS.
> My server must must persist, as I cannot handle issues with a dynamic
> server, so I want to use a server that can boot from EBS.

Hi Sanjay,

there are plenty of howtos to get centos in the cloud - google is your 
friend.
But one note: since C5.5 you do not need Amazon's kernel+initrd anymore, 
the Centos shipped xenblk and xennet modules work just fine. And finally 
amazon ships a thing as "boot kernel" that behaves like pygrub and reads 
the grub.conf of your image and starts the inside configured kernel.

I had to use this cmdline to make the initrd:
KVER=$(uname -a|awk '{print $3}')xen
mkinitrd --omit-scsi-modules --with=xennet --with=xenblk 
--preload=xenblk -f /boot/initrd-${KVER}.img ${KVER}

and my modprobe.conf:
alias eth0 xennet
alias scsi_hostadapter xenblk

To get an image into the cloud I did:
- format a 10GiB file with ext3
- install a minimal centos to it (yum with --installroot option)
- put this into S3 as an AMI
- start an instance of it
- clone this to an EBS file with rsync
- make a snapshot of this EBS
- convert this snapshot to an EBS AMI
- use your EBS instances...

Hth
Rainer