TvE 2100

At 2100 feet above Santa Barbara

Bundling-up an Ubuntu EC2 Instance

A customer of ours was trying to bundle-up an instance running Marcin’s public Ubuntu 6.10 image. Nothing wrong with that image, except that it is bare bones. It looks like Marcin intended it as a bootstrap image: it just helps you getting off-the ground so you can install exactly the packages you want and then you can bundle-up the results.

Well, in order to do that bundling-up you need to have the Amazon EC2 AMI tools installed, and those require things such as Ruby, OpenSSL, rsync, and a few more. In addition, they’re packaged as an RPM, so you need to have “alien” to convert the RPM into a DEB that dpkg can install. To cut to the chase, I spent quite a while poking around to get everything going. Here are the relevant commands in case you need to do the same.

First, let’s create some space to work in, download the AMI tools, convert them to a DEB and install them:

mkdir /mnt/ec2
cd /mnt/ec2
apt-get install alien
alien ec2-ami-tools.noarch.rpm
dpkg -i ec2-ami-tools_1.2-7222_all.deb

Now we need to take care of some prerequisites: ruby, the ruby-openssl interface, and rsync:

apt-get install ruby
cd /usr/lib/ruby/1.8
ln -s /usr/lib/site_ruby/aes .
apt-get install libopenssl-ruby
apt-get install rsync

Finally we need to patch-up the AMI tools to work on a debian-based system:

vi /usr/lib/site_ruby/aes/amiutil/image.rb

and around line 149 change:

exec( 'for i in console null zero ; do /sbin/MAKEDEV -d ' + dev_dir + ' -x $i ; done' )


exec("cd #{dev_dir} && /sbin/MAKEDEV console && /sbin/MAKEDEV std && /sbin/MAKEDEV generic")

Voila! Now you can hit the convenient “bundle” button on aws-console and some 10-20 minutes later you shall have your instance bundled up!