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( 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).
  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.
  4. On the temporary instance download conversion script and make it executable.
  5. Execute script: (i-xxxx in below is the instance id of the source PV instance)
  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.