DEV Community

Arun Kumar for AWS Community Builders

Posted on

1

How to recover an EC2 instance that doesn’t boot up

Background

  • Often, you might face issues with your EC2 and in some cases it doesn’t even boot up for you to check and troubleshoot the error. To know more about the error “EC2 instance unable to boot up properly”, check
EC2 -> Action -> Instance Setting -> Get System Log
Enter fullscreen mode Exit fullscreen mode

Steps

Traditional way

  • Stop the instance
  • Unmount the root volume and attach the root volume to another instance running the same AMI.
[root@instance-1]:/
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 10G 0 part /
xvdf 202:80 0 50G 0 disk /prod/applc/wls
xvdg 202:96 0 20G 0 disk /prod/applc/logs
xvdh 202:112 0 10G 0 disk
├─xvdh1 202:113 0 1M 0 part
└─xvdh2 202:114 0 10G 0 part
Enter fullscreen mode Exit fullscreen mode
  • In example above, root is /dev/xvdh
mount -o nouuid /dev/xvdh2 /mnt
Enter fullscreen mode Exit fullscreen mode
  • Check if the /mnt eg disk space full, or see /mnt/var/log/dmesg
  • Check if /mnt/etc/fstab got any issue with mount point.
  • If you don’t put the “nouuid” option, the mount will fail if the volume had the same UUID as the current root volume.
  • After fixing the issue, detach the Volume and attach back.
  • When attached back as root, make sure to mount as /dev/xvda or /dev/sda1

Snapshot method

If the above steps still don’t work, then you need to restore from SNAPSHOT. Do the following —

  • EC2→snapshot. Select the root snapshot and then Action → Create Image.

1

  • Change Virtualization type to Hardware-assisted.
  • Add the snapshot data volume, ensure the dev/sdx match the current instance and the size.
  • This will create a new AMI image which you can then use to spin up a new EC2 instance.
  • Once you test and verify this new EC2 instance is fine, you can stop the new instance, take the final backup before you terminate the instance.
  • If need to reuse the same IP then respin up the new AMI image with the IP required.

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Okay, let's go

Top comments (0)

Best Practices for Running  Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK cover image

Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK

This post discusses the process of migrating a growing WordPress eShop business to AWS using AWS CDK for an easily scalable, high availability architecture. The detailed structure encompasses several pillars: Compute, Storage, Database, Cache, CDN, DNS, Security, and Backup.

Read full post

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay