{"id":2835,"date":"2014-12-05T10:07:32","date_gmt":"2014-12-05T10:07:32","guid":{"rendered":"http:\/\/blog.cloudthat.com\/?p=2835"},"modified":"2024-06-25T11:14:03","modified_gmt":"2024-06-25T11:14:03","slug":"steps-to-convert-ubuntu-based-pv-instances-to-hvm","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/steps-to-convert-ubuntu-based-pv-instances-to-hvm","title":{"rendered":"Steps to convert UBUNTU-BASED PV instances to HVM"},"content":{"rendered":"<p>My previous <a href=\"https:\/\/blog.cloudthat.com\/steps-to-convert-rhel-based-pv-instances-to-hvm\/\">blog<\/a> will help you convert Rhel-based PV instances to HVM.<\/p>\n<p>In this blog, we will convert <b>Ubuntu based<\/b> PV instances to HVM.<\/p>\n<p>1. Start a new Ubuntu HVM machine.<\/p>\n<p>2. Start a Ubuntu PV machine from your existing AMI.<br \/>\n(or)<br \/>\nIf you are just testing then, install any simple package on it for instance, Apache.<\/p>\n<pre class=\"lang:default decode:true\">sudo apt-get update<\/pre>\n<pre class=\"lang:default decode:true\">sudo apt-get install apache2<\/pre>\n<p>3. Install grub on it.<\/p>\n<p><i>*<\/i><b><i>Grub<\/i><\/b><i> selects a specific kernel configuration available on a particular operating system&#8217;s partitions.<\/i><\/p>\n<pre class=\"lang:default decode:true\">apt-get install grub-pc grub-pc-bin grub-legacy-ec2 grub-gfxpayload-lists<\/pre>\n<p><i>*<\/i><b><i>Note:<\/i><\/b><i> 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.<\/i><\/p>\n<p>4. Stop PV instance.<\/p>\n<p>5. Detach the root volume (\/dev\/sda1) from PV instance.<\/p>\n<p>6. Attach the root volume of PV instance to the running HVM instance. For example, \/dev\/sdf.<\/p>\n<p>7. Login to your HVM instance and execute the following commands.<\/p>\n<p><i>*<\/i><b><i>Note:<\/i><\/b><i> You need to be root user to execute these commands : sudo su.<\/i><\/p>\n<p>a.<\/p>\n<pre class=\"lang:default decode:true\">mkdir -p \/mnt\/xvdf &amp;&amp; mount \/dev\/xvdf \/mnt\/xvdf<\/pre>\n<p>b. <b>rsync<\/b> is used for copying local files.<\/p>\n<pre class=\"lang:default decode:true\">rsync -avzXA \/boot\/ \/mnt\/xvdf\/boot\/<\/pre>\n<p>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.<\/p>\n<pre class=\"lang:default decode:true\">mount -o bind \/dev \/mnt\/xvdf\/dev &amp;&amp; mount -o bind \/dev\/pts \/mnt\/xvdf\/dev\/pts &amp;&amp; mount -o bind \/proc \/mnt\/xvdf\/proc &amp;&amp; mount -o bind \/sys \/mnt\/xvdf\/sys<\/pre>\n<p>d. <b>chroot<\/b> changes the root directory to that specified in path and then runs the command.<\/p>\n<pre class=\"lang:default decode:true\">chroot \/mnt\/xvdf<\/pre>\n<p>e. Grub modifications.<\/p>\n<pre class=\"lang:default decode:true\">grub-install --no-floppy --recheck --force \/dev\/xvdf<\/pre>\n<p>f. Update the grub changes, incase if the PV instance kernel version is not the same as HVM instance.<\/p>\n<pre class=\"lang:default decode:true\">update-grub2<\/pre>\n<p>g. Exit chroot: <b>CTRL+D<\/b>.<\/p>\n<p>8. Stop the HVM instance.<\/p>\n<p>9. Detach both the volumes:<br \/>\n<b>\/dev\/sda1<\/b> original root AND detach <b>\/dev\/sdf<\/b> PVM root.<\/p>\n<p>10. Attach the PV root volume to HVM instance as <b>\/dev\/sda1<\/b>.<\/p>\n<p>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).<\/p>\n<p><i>*<\/i><b><i>Note:<\/i><\/b><i> 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.<\/i><\/p>\n<p>12. Create an AMI from the running HVM instance, this will be HVM virtualized.<\/p>\n","protected":false},"author":219,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3606,3607,3665],"user_email":"prarthitm@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/2835"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/219"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=2835"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/2835\/revisions"}],"predecessor-version":[{"id":42357,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/2835\/revisions\/42357"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=2835"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=2835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}