AWS, Cloud Computing, Tutorials

2 Mins Read

Steps to convert UBUNTU-BASED PV instances to HVM

My previous blog will help you convert Rhel-based PV instances to HVM.

In this blog, we will convert Ubuntu based PV instances to HVM.

1. Start a new Ubuntu HVM machine.

2. Start a Ubuntu PV machine from your existing AMI.
If you are just testing then, install any simple package on it for instance, Apache.

3. Install grub on it.

*Grub selects a specific kernel configuration available on a particular operating system’s partitions.

*Note: If you are just testing, then you can open the public DNS of your instance in a new tab of your browser and you will see the default Ubuntu 14.04 Apache web page.

4. Stop PV instance.

5. Detach the root volume (/dev/sda1) from PV instance.

6. Attach the root volume of PV instance to the running HVM instance. For example, /dev/sdf.

7. Login to your HVM instance and execute the following commands.

*Note: You need to be root user to execute these commands : sudo su.


b. rsync is used for copying local files.

c. Make sure you specify the correct order of the file systems to be mounted when you are using bind option of the mount command.

d. chroot changes the root directory to that specified in path and then runs the command.

e. Grub modifications.

f. Update the grub changes, incase if the PV instance kernel version is not the same as HVM instance.

g. Exit chroot: CTRL+D.

8. Stop the HVM instance.

9. Detach both the volumes:
/dev/sda1 original root AND detach /dev/sdf PVM root.

10. Attach the PV root volume to HVM instance as /dev/sda1.

11. Start the HVM instance. Start the instance using AWS console. The HVM instance should now boot successfully and will be an exact copy of the old source PV instance (if you used the correct volume). Once you have confirmed that everything is working, the source instance can be stopped. Cleanup by removing all temporary volumes (source and destination).

*Note: If you are testing it out, then, you can open the public DNS of your instance in a new tab of your browser and you will see the default Ubuntu 14.04 Apache web page.

12. Create an AMI from the running HVM instance, this will be HVM virtualized.

Voiced by Amazon Polly




  1. Rick Provencio

    Jun 14, 2018


    My issue with this method is that my volumes show as “nmve0n1” which I think is the sda1 and “nvme1n1” also might be the sdf volume. I don’t know how to proceed with step 7 because there isn’t a /dev/xvdf directory with anything inside. Any help would be appreciated, thanks!

  2. Sumant

    Mar 27, 2018


    Worked perfectly! Thanks so much for this.

  3. Sohail Mohabbat Ali

    Feb 2, 2018


    Perfect, worked like a charm. After meltdown and spectre problems amazon is recommending to migrate instances from PV to HVM virtualization and this article helped me a lot.

  4. Aravinda Lokesh

    Jan 11, 2018


    Thanks really, that worked!!

  5. Joe

    Aug 8, 2017


    Are there specific criteria for the HVM AMI you choose? I can’t attach any PV volumes to my HVM instance. I get this error: “Error attaching volume: The instance configuration for this AWS Marketplace product is not supported. Please see the AWS Marketplace site for more information about supported instance types, regions, and operating systems.”

  6. n4j

    Mar 3, 2017


    Worked for me. Thanks!!!!

  7. David

    Feb 4, 2017


    Worked perfectly! Thanks so much for this.

  8. Graeme Pyle

    May 15, 2016


    Man, thanks very much for this. It worked like a charm, and it will save me a lot in AWS fees going forward!

  9. Shrenik

    Sep 8, 2015


    Thanks. This works like a breeze. Nice guide.

  10. Click to Comment