Steps to convert UBUNTU–BASED PV instances into HVM
My previous blog will show you how to convert Rhel-based PV instances into HVM.
This blog will show you how to convert Ubuntu-based PV instances into HVM.
1. Start a new Ubuntu HVM system.
2. You can start a Ubuntu PV system from an existing AMI. If you are testing it, install any package, such as Apache, on it.
sudo apt-get update1sudo apt-get update
sudo apt-get install apache21sudo apt-get install apache23. Install grub on to it.
*Grub selects the kernel configuration that is available on a particular operating systems’ partitions.
apt-get install grub-pc grub-pc-bin grub-legacy-ec2 grub-gfxpayload-lists1apt-get install grub-pc grub-pc-bin grub-legacy-ec2 grub-gfxpayload-lists*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 using PV.
5. Remove the root volume (/dev/sda1) form the PV instance
6. Attach the root volume for the PV instance to the HVM instance. For example, /dev/sdf.
7. Log in to your HVM instance, and execute the following commands.
*Note: To execute these commands, you must be root user: sudo su
mkdir -p /mnt/xvdf && mount /dev/xvdf /mnt/xvdf1mkdir -p /mnt/xvdf && mount /dev/xvdf /mnt/xvdfb. rsync can be used to copy local files.
rsync -avzXA /boot/ /mnt/xvdf/boot/1rsync -avzXA /boot/ /mnt/xvdf/boot/c. When using the mount command, bind options must be used to specify the correct order of file systems.
mount –o binding /dev/mnt/xvdf/dev and mount –o binding /sys/mnt/xvdf/dev/pts and mount –o binding /proc/mnt/xvdf/proc and mount o binding /sys/mnt/xvdf/sysd. chroot changes the root directory according to path and then runs this command.
chroot /mnt/xvdf1chroot /mnt/xvdfe. Grub modifications
grub-install –no-floppy –recheck –force /dev/xvdf1grub-install –no-floppy –recheck –force /dev/xvdff. In case the PV instance kernel version is different than HVM instance, update the grub changes
update-grub21update-grub2g. Exit chroot: CTRL+D.
8. Stop the HVM instance.
9. Detach the volumes:/dev/sda1 root original AND /dev/sdf root PVM.
10. Attach the PV root volume as /dev/sda1.
11. Start the HVM instance. The AWS console will start the HVM instance. If you used the correct volume, the HVM instance should now be able to boot. Once everything is working properly, you can stop the source instance. Clean up by removing any temporary volumes (source or destination).
*Note: You can test it out by opening the public DNS of the instance in a new browser tab. The default Ubuntu 14.04 Apache web site will then be displayed.
12. Create an AMI from your running HVM instance. This will allow you to virtualize HVM.