Converting AWS EC2 PV(Para Virtual) instance to HVM instance

This post is useful to those who want to convert AWS ec2 instance from PV type to HVM type.

Linux Amazon Machine Images(AMI) uses two type of virtualization which is either ParaVirtual (PV) or Hardware Virtual Machine (HVM).

If you are running any AWS ec2 instance having PV virtualization type and wants to upgrade the instance to different Instance Family(https://aws.amazon.com/ec2/instance-types/) which only supports HVM virtualization type then AWS does not allow direct upgrade of instance type to different family(like c3 class to c4 class) so the existing instance must be converted to HVM virtualization type and then only the instance can be upgraded to other instance family type.

So below are the steps to convert the instance from PV to HVM virtualization type.

  1. Install grub on the source PV instance.(The instance which you want to upgrade).
    sudo yum install grub -y
    or
    sudo apt-get install grub -y
  2. Launch a temporary Amazon Linux instance (PV or HVM) in the same region as the source PV instance.
    Note: We will run a script from step-5 below to generate an AMI so it doesn’t matter what’s the configuration is for the new temporary instance as long as it’s in the same region as the source instance.
  3. Install the jq filter on the temporary instance.
    sudo yum install jq
    or
    sudo apt-get install jq
  4. On the temporary instance download conversion script and make it executable.
    wget https://s3.amazonaws.com/jacquecp/pv-hvm-latest-v2.sh;
    chmod +x pv-hvm-latest-v2.sh;
  5. Execute script: (i-xxxx in below is the instance id of the source PV instance)
    sudo ./pv-hvm-latest-v2.sh i-xxxx
  6. Follow the prompts and you will need to wait a while as this process will take some time. On completion, a new AMI id will be available and displayed on the console.
    during execution of the script you will need to provide access key, secret key, region information for AWS CLI configuration setup so keep this information handy during conversion.
  7. Launch an HVM instance from the new AMI id provided to replace your PV instance.

Reference: https://forums.aws.amazon.com/thread.jspa?messageID=648055

About the Author

Sandeep Agrawal
working @ Kalpavruksh Technologies as Software Engineer. I am a simple and straightforward person adaptable to any environment and work culture. Like to work in a creative and challenging environment using cutting edge technologies where I could constantly learn and successfully deliver solutions to problems.

12 Comments on "Converting AWS EC2 PV(Para Virtual) instance to HVM instance"

  1. hi
    I do this for aws ec2 pv to hvm , but i get error .

    Finalizing snapshot(s) for final AMIparse error: Invalid numeric literal at line 1, column 3
    ./pv-hvm-latest-v2.sh: line 1152: /usr/bin/jq: Argument list too long
    ./pv-hvm-latest-v2.sh: line 48: /usr/bin/seq: Argument list too long

    Please help me and thank you very much.

    • Can try doing the below and check.
      1) Detach the instance store volume from the source instance
      2) Use the script to create the HVM AMI of the source instance (without the instance store volume)
      3) When launching an instance using the created HVM AMI, attach the instance store volume.

      Even if it does not work then may be you can contact with aws support to see if they can help with the script as the mentioned script might not be working in your case and if aws support can provided updated script then that can help.

  2. Your script worked great! Thanks for the help.
    The only issue I ran into is that my instances were using the newer instance format (17 character format).
    I updated the instance ID length line in your code to support only the 17 character instance ID: https://s3.amazonaws.com/files.dgdean.com/pv-hvm-latest-v3.sh

    If you are still using the old use the one in the guide above.

    • Hey Alex, Its good to hear that the script worked great and helped you.
      Thanks for sharing the updated script to support for 17 character instance ID which is the latest format updated by aws team.

      Thanks again. 🙂

  3. Rajani Kumar | July 31, 2017 at 1:01 PM | Reply

    Hi,
    I used https://s3.amazonaws.com/files.dgdean.com/pv-hvm-latest-v3.sh script .but new AMI virtualization type is still paravirtual.

    plz help.

    • If your new type is still paravirtual then may be the process was not completed properly as it should.

      There must be some log file created by this process.
      look at /tmp folder to see if there is any file name like pv-hvm-latest-v3.sh.xxxx.log (/tmp/pv-hvm-latest-v3.sh.xxxx.log)
      and see if there are any errors in the log file which you might want to look at and fix.

  4. Hi, on step 2 “Launch a temporary Amazon Linux instance in same region as the source PV instance” this instance has to be PV or HVM?

    • Hi,

      The temporary instance can be PV or HVM.
      As we will run a script in step-5 to generate an AMI, it doesn’t matter what’s the configuration is for the new temporary instance as long as it’s in the same region as the source instance.

      I have updated the step 2 section now.
      Thanks for asking this question, It helped me update this post. 🙂

  5. The latest version of the original sh script in step 4 is available at the below link (exclude any vX from the uri).. this will add support for long instance ids, which is not supported by the original script;

    https://s3.amazonaws.com/jacquecp/pv-hvm-latest.sh

Leave a comment

Your email address will not be published.


*