DEV Community

loading...
AWS Community Builders

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

Arun Kumar
AWS Community Builder
・2 min read

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.

Discussion (0)