Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to create a hardware virtual machine (HVM) AMI from an existing paravirtual (PV) AMI.

My initially thought was to start a new PV instance and use the ec2-create-image command to create a new image while specifying HVM as the virutalization type. However, ec2-create-image does not have a command line parameter to specify the virtualization type.

Is there another way to go about doing this?

share|improve this question

2 Answers 2

Update

AWS has enabled this feature in the EC2 API. It is available as the --virtualization-type option to aws ec2 register-image in the new Boto based awscli.

Original answer

Yes! Unfortunately, there is not a direct way to do so. Also, some PV instances may need kernel and bootloader modifications.

  1. Create a volume from your existing PV AMI. If it was your own PV AMI, you can make a volume from the snapshot. If it is a 3rd party AMI, you will need to launch an instance and take a snapshot.
  2. Launch an HVM instance with any AMI.
  3. Stop that HVM instance.
  4. Detach the root volume from that instance.
  5. Attach the PV volume as the root volume(/dev/sda1 or /dev/sda if it was partitioned) to the HVM instance.
  6. Run ec2-create-image on the HVM instance.
  7. Launch other instances with your new HVM AMI.

If that doesn't work, then before step 5, you will need to attach that volume to a running instance, set up a chroot, and install a kernel and bootloader for your distribution. You may also want to clear logs and any cloud-init cache.

share|improve this answer

TLDR:

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 

Detailed steps:

Answering further based upon Jeff Strunk's response to simplify the steps and giving a bit more details on the ec2 register image:

  1. Create Instance using PV Image. Make / update any changes you want.

  2. Create Image from the above instance.

  3. 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:

    ec2-describe-images ami-id_of_above_created_ami

    and find the snapshot id for the ami

    .. Assumptions for further steps: Your ec2 keys and api tools are set and ready to use:

  4. Register a new HVM AMI using the above snapshot: example:

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

where

  • -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.

share|improve this answer
    
Unless I'm doing something wrong, this will not work for marketplace AMIs that restrict instance types. Tried converting the official MongoDB paravirtual AMI to HVM, and while I could create the HVM AMI, it wouldn't launch an HVM-instance with it. –  Matt Beckman Aug 25 at 17:46
    
@MattBeckman I think its about the underlying kernel/bootloader support rather than AMI restriction. Above works for fedora but not for amazon linux. There you have to go the way as suggested by Jeff Strunk originaly. –  Anshu Prateek Sep 1 at 3:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.