Skip to content
Home » Converting AWS EC2 PV(Para Virtual) instance to HVM instance

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

14 thoughts 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.

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

    1. 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. 🙂

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

  2. 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?

    1. 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. 🙂

  3. I’m getting stuck at “Preparing source device..”

    I think because /dev/sdj is a symlink to /dev/nvme1n1?
    lsblk output is
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    nvme0n1 259:0 0 256G 0 disk
    ├─nvme0n1p1 259:3 0 256G 0 part /
    └─nvme0n1p128 259:4 0 1M 0 part
    nvme1n1 259:1 0 8G 0 disk

Leave a Reply

Your email address will not be published. Required fields are marked *

0 Shares
Tweet
Pin
Share
Share
Share