View source | Discuss this page | Page history | Printable version   

Release Management/Rebundling Professional Appliance AMIs

Release Management/Internal




This document is intended to be a guide when is needed to rebuild a openbravo rpath ops AMI. This process can be done in two ways:

Process simple:

  1. Start an instance of the AMI that need to be modified
  2. Make the changes
  3. Make an ec2-rebundle-vol, this generates an AMI with the current state of the instance.

Process complex and clean (oriented to publish the AMI to customers):

  1. Start an instance of the AMI that need to be modified
  2. Make the changes
  3. Extract the modified files
  4. Apply the modified files into a clean instance of the same AMI
  5. Generate the AMI from there.

This document are only related to the second type of process, the one oriented to customers.


Ami and Api tools of EC2

Follow this guide to setup ec2-tools and ec2-ami-tools:

Also is recommend to read this document:

Environment variables

Check that this variables are in you .bashrc (replace 'x' with your credentials)

export EC2_AMITOOL_HOME=/usr/local/ec2-ami-tools
export EC2_HOME=/usr/local/ec2-api-tools
export PATH=$PATH:/usr/local/ec2-ami-tools/bin:/usr/local/ec2-api-tools/bin
export EC2_PRIVATE_KEY=/home/openbravo/.ec2/pk-xxxxxxxxxxxxxx.pem
export EC2_CERT=/home/openbravo/.ec2/cert-xxxxxxxxxxxxx.pem
export EC2_URL=''
export EC2_USER_ID=xxxxxxxxxxxxx
export EC2_ACCESS_KEY=xxxxxxxxxxxxxxxxx
export EC2_SECRET_KEY=xxxxxxxxxxxxxxxxxxx

You should have an ".ec2" folder in your home with the certificates (pk-xxxx.pem, cert-xxxxx.pem and user-johndoe-eu.pem)

Disk space

Taking into account that each AMI can have about 10GB, in this process you will need more than 20 GB, but better if you have more disk space.

Internet connection

Some parts of the process need a really good Internet connection (be able of upload 0,5-1GB without interruptions), is highly recommended to execute the steps marked with "NET+++" in a temporally amazon instance. The steps that is enough with a normal Internet connection are marked with "NET+" and can be executed from the user computer.

Also is recommended for the high hdd usage to use a medium or large instance, because the hdd performance in small instances are very poor.

In the temporal amazon instance is necessary to install the ami-tools.


Download the original


You can download from the ops mountable image, is a file with extension ".fs.ext3".

And uncompress it:

tar xzvf ops-2.50-x86.fs.tar.gz -C original

Create an AMI with the original


ec2-bundle-image -i original/ops-2.50-x86/ops-2.50-x86-root.ext3 -r i386 -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $EC2_USER_ID
Bulbgraph.png   bucket name (-b option below) is unique across Amazon S3, so the below may throw error. Remember not to paste EC2_SECRET_KEY/EC2_ACCESS_KEY public
ec2-upload-bundle -b original -m /tmp/ops-2.50-x86-root.ext3.manifest.xml -a $EC2_ACCESS_KEY -s $EC2_SECRET_KEY --location EU
ec2-register original/ops-2.50-x86-root.ext3.manifest.xml

This command should return the AMI id: ami-xxxxxxx

Startup the original


Start an instance of the original AMI:

ec2-run-instances -g tmp -t c1.medium ami-xxxxxx -k user-johndoe-eu

Thi shoul return the instace id i-xxxxxx, check when is ready the instance and the IP (to see the ip needed to be the instance completely loaded).

watch -n 10 ec2-describe-instances i-xxxxxx

Save the ip of the machine for connect by ssh.

Make changes


Connect to the origianal instance:

ssh ip

Make the necessary changes


If you are distributing openbravo binaries is mandatory to delete the checksums file:

rm -r /opt/OpenbravoERP/config/checksums

If you have updated core, probably you don't want to package in the AMI the backup:

rm -r /opt/OpenbravoERP/backup_install

Compress the changes

Create a compress file with the changes in database, sources and tomcat (the specified folders correspond with a rpath linux)

tar czvf /tmp/a.tar.gz /srv/pgsql /opt/OpenbravoERP /var/lib/tomcat/webapps/openbravo

For make easy to download, you can copy the file to the web folder :)

cp /tmp/a.tar.gz /srv/www/html

Donwload the changes


wget ip/a.tar.gz

Apply the changes


Two bad options:

  1. Mount the image and uncompress the file with the changes from outside. Then the owner and group of the files are wrong and take any of the machine in which we are.
  2. Mount the image, copy the file inside and uncompress. The problem here is that we are adding the size of the file to the bundle, that after uncompress and delete the compress file, we don't free again. This is because a ext3 file that once is extended can't be compressed the same as before instead it has the same used space.

So the correct way is this:

Uncompress the original fs.ext3 in a new folder

mkdir modified
tar xzvf ops-2.50-x86.fs.tar.gz -C modified

Mount the files

mkdir ori
sudo mount -o loop original/ops-2.50-x86/ops-2.50-x86-root.ext3 ori
mkdir ori/mnt/mod
sudo mount -o loop modified/ops-2.50-x86/ops-2.50-x86-root.ext3 ori/mnt/mod


Copy the file with the changes to the original:

cp /tmp/a.tar.gz ori/

Chroot to original and extract the file in the modified. This peserve the file size of the modified ami and the file permissions in the extracted files

sudo chroot ori
tar xzpvf /a.tar.gz -C /mnt/mod/


The files extracted are here if you want to check that the process is correct

ls -al /mnt/mod/srv/pgsql
ls -al /mnt/mod/opt/OpenbravoERP
ls -al /mnt/mod/var/lib/tomcat/webapps/openbravo

Umount files

Exit of the chroot and Unmount volumes

umount ori/mnt/mod
umount ori

Generate the bundle


Generate the bundle

ec2-bundle-image -i mod/ops-2.50-x86/ops-2.50-x86-root.ext3 -r i386 -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $EC2_USER_ID

Upload the bundle

ec2-upload-bundle -b new-bucket -m /tmp/ops-2.50-x86-root.ext3.manifest.xml -a $EC2_ACCESS_KEY -s $EC2_SECRET_KEY --location EU

Register the AMI


ec2-register new-bucket/ops-2.50-x86-root.ext3.manifest.xml

Give permissions


By default the AMI is private you can make it public, or especified the users that can use it:

ec2-modify-image-attribute -a user_id(without '-') -l ami-xxxxx
Bulbgraph.png   If you don't need more, remember to shutdown the temporally instance that we have use for the process. Also the original AMI instance if is no needed it can be halted.

Retrieved from ""

This page has been accessed 5,058 times. This page was last modified on 2 February 2010, at 07:45. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.