Created: 2012-03-26 05:17
Updated: 2014-04-14 05:22
License: mit


Uncloud / Recloud

Ubuntu cloud images helper and EC2/Openstack AMI publisher


Canonical provides a build of ubuntu setup for OpenStack Amazon EC2. These VMs are configured to run on EC2, consumes the EC2 init parameters and more.

More info: Canonical's cloud portal.

To run those ubuntu builds on a local hypervisor, some changes are necessary. The uncloud script runs through those changes.


Import an ubuntu VM archive into EC2 and publish it as an EBS based AMI. A lot of this work is derived from Eric Hammond's blog post Creating Public AMIs Securely for EC2, and his shell script alestic-git-build-ami

Important note: this script assumes that the VM archive can be run by the EC2/Openstack hypervisor. Potential pitfalls that this script does not resolve:

  • the hypervisor does not understand the partition
  • the kernel will panic (hint: use the 'virtual' build of the kernel)
  • the runtime parameters passwed to the VM (ssh keys) are not taken into account by the VM (hint: apt-get install cloud-init)

This script is used at the moment with the a VM created from 'uncloud'. That type of VM is originally made to run on EC2/Openstack. It works fine when re-imported into it.

Another project similar to this is here: https://github.com/kickstarter/build-ubuntu-ami



git clone http://github.com/hmalphettes/ubuntu-uncloud-recloud
cd ubuntu-uncloud-recloud

Script description

  • Download the latest 12.04 cloud image
  • Clone it in the raw format
  • Grow its partition from 2G to 15G
  • Mount it locally
  • Setup the ubuntu user with the ubuntu password via grub
  • Disable the cloud-init service
  • Clone the disk in vmdk format

Ready to be run in your favorite hypervisor.


  • OS Linux; tested on ubuntu
  • e2progs: e2fsck, resize2fs, fdisk
  • qemu-img, qemu-nbd
  • VBoxManage: vmdk conversion (optional)



Define the EC2 keys as environment variables:


Define the URL of the Ubuntu VM archive to download as the environment varable


Place the pk-.pem and cert-.pem files in ~/.ec2 Check the script and run it:

git clone http://github.com/hmalphettes/ubuntu-uncloud-recloud
cd ubuntu-uncloud-recloud


  1. Downoad the VM archive (if necessary)
  2. Unzip it (if necessary
  3. Locate the VM file (if necessary)
  4. Clone the VM file into a raw VM file if the VM file is a vmdk (necessary for qemu-nbd).
  5. Mount the VM file on the file system with qemu-nbd
  6. Run the script lib/recloud-mounted-img.sh to reverse uncloud.
    • reset the grub config to a ubuntu cloud image
    • reset the ubuntu user's password
    • harden the /etc/sshd_config to only accept public keys for authentication
    • delete the chef-connection parameters if present
    • delete the /home/ubuntu/.ssh/ keys and known_hosts
    • wait for the user to manually tweak other things
  7. Create a new EBS volume, attach it and mount it to the current instance.
  8. Copy into the VM's content into the EBS volume.
  9. Unmount everything
  10. Create a snapshot of the EBS volument and publish it as an AMI.


1- init job to lazy configure the sshd's keyx; just like cloud-init does but we are disabling it) 2- map to the hostname (not a blocker)

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more