{"id":349,"date":"2021-11-12T16:03:12","date_gmt":"2021-11-12T21:03:12","guid":{"rendered":"http:\/\/peshvar.com\/myblog\/?p=349"},"modified":"2021-11-12T16:03:42","modified_gmt":"2021-11-12T21:03:42","slug":"aws-issue-with-cloud-init-service-cloud-config-script","status":"publish","type":"post","link":"https:\/\/peshvar.com\/myblog\/2021\/11\/12\/aws-issue-with-cloud-init-service-cloud-config-script\/","title":{"rendered":"AWS-issue with Cloud-init service\/cloud-config script"},"content":{"rendered":"\n<p>In certain cases, the cloud-init service might stop and that would cause the AWS instance to not boot. Use the following steps to recover:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Launch a new recovery instance of type t2.micro(x86x64) in the same Availability Zone (ie us-east-1a). Ensure that you enable a public ip or associate an elastic ip with this recovery instance to access internet.<\/li><li>Detach the root volume of the impaired instance <\/li><li>Attach the volume as a secondary volume to the recovery instance.<\/li><li>SSH into the recovery instance and mount the volume the secondary volume.<br># sudo su &lt;\u2014\u2014\u2014\u2014\u2014\u2014 become a root user.<br># sudo mkdir \/mnt\/recovery &lt;\u2014\u2014\u2014\u2014\u2014\u2014 make a directory.<br># sudo mount \/dev\/xvdf1 \/mnt\/recovery &lt;\u2014\u2014\u2014\u2014\u2014\u2014 Mount the secondary volume to the recovery instance.<br># mount -o bind \/proc \/mnt\/recovery\/proc<br># mount -o bind \/dev \/mnt\/recovery\/dev<br># mount -o bind \/sys \/mnt\/recovery\/sys<br># chroot \/mnt\/recovery <code># cd \/ # ll \/etc\/resolv.conf # rm -f \/etc\/resolv.conf # echo \"nameserver 8.8.8.8\" &gt; \/etc\/resolv.conf # apt update # apt remove cloud-init # apt purge cloud-init -y # apt install cloud-init -y # cd \/var\/lib\/cloud\/ # rm -rf * # cd # exit &lt;\u2014\u2014\u2014\u2014 we have come out of the chroot using exit command. # umount \/mnt\/recovery\/{proc,sys,dev} &lt;\u2014\u2014\u2014\u2014 and now we have to unmount the secondary volume. # umount \/mnt\/recovery # lsblk &lt;\u2014\u2014\u2014\u2014 to confirm if volume has been unmounted.<\/code><\/li><li>Now, you can detach the secondary volume and attach it to the original instance: as \/dev\/sda1.<\/li><li>Now, create a new AMI from the impaired instance and launch a new instance of your choice.<\/li><\/ol>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In certain cases, the cloud-init service might stop and that would cause the AWS instance to not boot. Use the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[4],"tags":[],"class_list":["post-349","post","type-post","status-publish","format-standard","hentry","category-information-technology"],"_links":{"self":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts\/349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/comments?post=349"}],"version-history":[{"count":2,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts\/349\/revisions"}],"predecessor-version":[{"id":351,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/posts\/349\/revisions\/351"}],"wp:attachment":[{"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/media?parent=349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/categories?post=349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peshvar.com\/myblog\/wp-json\/wp\/v2\/tags?post=349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}