In this blog post, I am going to tell you how to setup a Fedora HVM Image from the official Fedora PV Image on Amazon EC2. In general, this basically covers how to convert a PV image into a HVM image for AWS EC2. This works for fedora, but might not work for other OSes.
I assume you know about AWS, EC2, AMI, HVM and PV. Amazon has been steadily pushing towards using HVM. With the latest round of launches on July 1, 2014, Amazon now shows only HVM Images by default when you go to launch an instance. You now have to search for PV images. One benefit of using HVM images is better access to underlying hardware resources which gives benefits such as enhanced networking.
Fedora has official Amazon AWS EC2 AMIs available at http://cloud.fedoraproject.org/. However presently it only has para-virtualized (PV) Images.
I have been working extensively on AWS EC2 for the last few weeks and have realized that for best performance, we should be using HVM images.
The first step is to spin up an instance from the existing PV AMI. Its not completely necessary, since you just need the snapshot of the AMI. However I created an instance as I needed to make some changes to the image. The existing AMI available from Fedora has Kernel 3.10. So, I had to do a yum upgrade to get the latest available kernel 3.15.
After launching the instance from PV and making changes as per your needs (in my case, sudo yum upgrade -y), create a new AMI using AWS tools or web console, whatever way you are comfortable with.
After the AMI is ready, find the snapshot id used by the above AMI under EC2 > Elastic Block Store > Snapshot in EC2 Console.
or if you have the ec2 api tools setup:
and find the snapshot id for the ami. It would be something like snap-a12b34cd .
Once you have the snapshot id, you can register a new AMI using the above snapshot.
To register a new HVM AMI using the above snapshot, you need to use the cli/api tools since AWS still doesn’t have this in the webconsole (it might come soon).
ec2-register -a x86_64 -d '3.15.7-200.fc20.x86_64' -n 'Fedora_20_HVM_AMI' --sriov simple --virtualization-type hvm -s snap-b44feb18 --root-device-name /dev/sda1
-d is AMI description
-n is AMI name
-s is snapshot id from step 3.
-a is architecture
–virtualization-type is required for making it hvm
–sriov is for enabling enhanced networking , though it might be redundant, not sure.
This would register/create a new HVM AMI based on the snapshot created by the PV Image.
So, in this blog, we discussed how you can convert an existing PV AMI into an HVM AMI, specifically, how to create a fedora HVM AMI from the official PV AMI.
PS: I have made my Fedora HVM AMI public in the east region. So just search for Fedora and you will find it. Feel free to create AMIs of your own and/or copy it over to other regions.
PPS: Wanna know which cool place do I work where we end up playing with the state of the art latest technologies, be it kernels or the latest SSDs? Hit over to http://aerospike.com/careers to join the team!