Colin Percival created his own EC2 import volume for importing FreeBSD images.
http://www.daemonology.net/blog/2014-11-26-missing-importvolume-documentation.html
It uploads a volume to EC2, takes a snapshot and registers the snapshot as an
AMI - these are the essential steps required to convert for example a local Xen
HVM image to run as an EC2 HVM image.
I have tested on Linux and it seems to work fine except for one glitch which is
that the created volume is 10 gigabytes instead of one gigabyte. This doesn’t
prevent it working but for testing purposes you probably want to delete
everything ASAP after seeing it work. I suspect the problem is that EC2’s
importvolume API expects you to specific either nothing or a number of
gigabytes as the target volume size and for some reason that’s wrong. I
haven’t had time to investigate in depth yet. It’s in here in main.c if you
are interested:
importvolume(const char * region, const char * bucket, const char * manifest,
uint64_t size, const char * key_id, const char * key_secret)
One thing to note is that if you are running this from outside EC2 then of
course the file upload is slow….. so there’s still actually good reason to run
it from an instance within EC2 because it’s many times faster to do the upload.
To get it going on ubuntu:
apt-get install libssl-dev bmake
git clone https://github.com/cperciva/bsdec2-image-upload
edit the Makefile and changing the WARNS line to "WARNS ?= 0”.
Make this change in main.c
//#define CERTFILE "/usr/local/share/certs/ca-root-nss.crt"
#define CERTFILE "/etc/ssl/certs/ca-certificates.crt”
bmake
you will then have a bsdec2-image-upload binary that should work.
To run:
create a file named awskeys.txt which will be passed into bsdec2-image-upload
ACCESS_KEY_SECRET=<your AWS secret key>
ACCESS_KEY_ID=<your AWS access key ID>
to cast the spell:
assuming your Xen HVM image is hvmbootimage.img
create an S3 named myimportbucketname (S3 bucket names must be unique so you’ll
need your own bucket name)
bsdec2-image-upload/bsdec2-image-upload hvmbootimage.img hvmbootimage.img
hvmbootimage.img us-west-1 myimportbucketname awskeys.txt
it should then transfer your image and if you wait patiently you’ll end with an
HVM AMI that you can execute.
thanks to Colin for helping me get it going on Linux.
as