Centos 5 AMI for Amazon EC2 install script October 29th, 2008
Excited about the load balancing, auto-scaling and other new features coming to Amazon EC2?
Here's a script to bootstrap a lean 32bit Centos 5 into m1.small AMI-form for use on EC2. I started with the Rightscale scripts and removed the interactivity and RightScale specifics and added some features: it's using a mirror based yum config to do a base install and I added the same scripts you can find on the Fedora AMI from Amazon itself to update the ec2-ami-tools and kernel-modules. I also included a couple of Dag's packages like dstat and others from RPMForge
Insert your AWS specifics in the top of the file, choose a bucket to store the bundles AMI in, and give your image a nice name. To bootstrap just launch a Fedora 8 instance (use ami-2b5fba42), copy over the script, your certificate and key, and run the script. With some luck - and no boobo on my part - you should see this in your terminal at the end:
Done! Put a fork in it!
Baking the AMI can take a while, so be patient. Afterwards you need to register this AMI so it shows up in your ec2-describe-images -o self command:
ec2-register your-bucket-name/image-name.manifest.xml
This is currently for a 32bit m1.small AMI only, I'm hoping to use some kind of template system to be able to bake a similar script for 64bit and 32bit AMI's alike.
The script:
Querying RPM for 32bit and 64bit versions April 2nd, 2008
Query all:
[root@server ~]# rpm -qa --qf '%{name}.%{arch}\n'
hdparm.x86_64
rootfiles.noarch
basesystem.noarch
libsepol.x86_64
gmp.x86_64
...
Query specific packages:
[root@server ~]# rpm -q --queryformat='%{n}-%{v}-%{r}.%{arch}\n' glibc
glibc-2.3.4-2.39.x86_64
glibc-2.3.4-2.39.i686
Centos 5 kernel 2.6.18-53.1.6.el5xen initrd missing xenblk modules February 6th, 2008
Update: newer kernel & initrd 2.6.18-53.1.13.el5xen doesn't have this problem.
If you're running Centos5 and recently upgraded a Xen domU kernel to 2.6.18-53.1.6.el5xen you maybe got burned by the following problem:
Loading xenblk.ko module XENBUS: Timeout connecting to device: device/vbd/51712 (state 3) Scanning and configuring dmraid supported devices Creating root device. Mounting root filesystem. mount: could not find filesystem '/dev/root' Setting up other filesystems. Setting up new root fs setuproot: moving /dev failed: No such file or directory no fstab.sys, mounting internal defaults setuproot: error mounting /proc: No such file or directory setuproot: error mounting /sys: No such file or directory Switching to new root and running init. unmounting old /dev unmounting old /proc unmounting old /sys switchroot: mount failed: No such file or directory Kernel panic - not syncing: Attempted to kill init!
Apparently the initrd is missing the xenblk module and any domU that's using tap:io in its Xen config can't connect to it's virtual disk image.
Here's the fix:
Change tap:io into file: in your xen configs and boot the domU.
disk = [ 'tap:aio:/var/lib/xen/images/domU.img,xvda,w', ]
into
disk = [ 'file:/var/lib/xen/images/basestar.img,xvda,w', ]
In your booted domU:
cd /boot rm /boot/initrd-2.6.18-53.1.6.el5xen.img mkinitrd -v --with=xenblk --omit-scsi-modules --omit-raid-modules /boot/initrd-2.6.18-53.1.6.el5xen.img 2.6.18-53.1.6.el5xen
Now you can change back to tap:io in your domU config and reboot the domU. You'll need to do this for every domU that has been upgraded to the 2.6.18-53.1.6.el5xen kernel.
See http://bugs.centos.org/view.php?id=2083 and http://bugs.centos.org/view.php?id=2543 for more info
