Building Gentoo Images For Amazon EC2
Posted by Stuart Herbert @ 8:52 PM, Thu 07 Sep 06
Filed under: Xen
6 Comments
The online press has been abuzz this week with the news that Amazon’s EC2 service has gone into beta. EC2 is a big Xen server farm in the sky, where you pay by the hour that your Xen virtual machine is running, and by the amount of bandwidth you consume. If you need a server running 24×7, then renting a dedicated server is probably cheaper than using EC2. But … if you only need a server running for part of the day (for example, during office hours), or if you have a service that can scale horizontally, then EC2’s well worth a look.
I’m currently re-installing Gentoo from scratch on my dual-Xeon box, and converting it over to be a local Xen test box, so that I can create some Gentoo AMIs (Amazon Machine Images) locally before uploading them to EC2. I’ll start off with a generic LAMP Server, and see where to go from there.
If you’re interested in lending a hand, give me a shout.

6 Comments
September 8th, 2006 at 3:47 am
I have a basic gentoo 2006.1 server profile ami running on ec2. I built it on the fedora image on ec2. It seems to make more sense to build amis on machines running on ec2 because the bandwidth between ec2 machines is free. There are a couple of issues with using gentoo on ec2. The main one is the lack of data retention during reboots. It is equivalent to using an lvm cow snapshot on xen. The problem is that everytime you emerge world, the changes must to packaged into an ami and uploaded to S3. In this regard, we really need an ec2-ami-tools ebuild to process the bundling and upload of the changed image. Its all ruby code but I haven’t figured out the Redhat specific pieces. The Amazon key-pair did not work with the Gentoo image. I was able to ssh in by password and set up my on keys. The pub key from configured from the key-pair is available in /mnt but I don’t know how they are using it automatically under fedora. If you need anything from me let me know.
September 8th, 2006 at 9:53 am
Hi Harris,
Thanks for the feedback. I think you’re right; packaging the AMI tools in an ebuild is a good place to start. I’ll get into it!
Can I bug you with questions as I go along? I haven’t used EC2 or S3 at all yet; I’m sure there are things about it that I haven’t picked up from the docs.
Best regards,
Stu
September 8th, 2006 at 1:31 pm
email me with any questions.
Harris
September 8th, 2006 at 7:24 pm
I found somethings that may be useful to you in getting the ami-tools working on my ec2-gentoo image. There is a /usr/lib/site_ruby/aes directory which should be under /usr/lib/ruby/site_ruby on gentoo. There is an /etc/aes/amiutils directory which must be copied to /etc and there is a /usr/local/aes/amiutil directory which contains all the executables and /usr/local/bin directory which has links to programs in /usr/local/aes/amiutils.
curl is an rdepend as is ruby.
ec2-bundle-vol does some fedora specific things. Look in the /etc/aes/amiutils directory.
This is from the fedora equiv of local.start
if [ -e /mnt/openssh_id.pub ] ; then
cat /mnt/openssh_id.pub >> /root/.ssh/authorized_keys
Thats how the key-pair stuff works.
September 21st, 2006 at 8:11 am
To install the tools on gentoo:
# rpm2targz ec2-ami-tools.noarch.rpm
# tar xzf ec2-ami-tools.noarch.tar.gz
# cp etc/aes/ /etc/ -r
# cp usr/lib/site_ruby/ /usr/lib/ -r
# cp usr/local/* /usr/local/ -r
# export RUBYLIB=/usr/lib/site_ruby/
September 21st, 2006 at 9:56 am
To get rid of the MAKEDEV error:
Boot with the livecd, mount your root, chroot into it and do:
cp -a /dev /root/dev-copy
In /usr/lib/site_ruby/aes/amiutil/image.rb replace:
exec( ‘for i in console null zero ; do /sbin/MAKEDEV -d ‘ + dev_dir + ‘ -x $i ; done’ )
with:
exec( ‘cp -a /root/dev-copy ‘ + IMG_MNT )
Also, it might be a good idea to exclude usr/portage/distfiles when running ec2-bundle-vol (-e parameter.)
Add Your Comments To This Article Using The Form Below
Your comments may not appear until they have been approved by a moderator.