How to: Recover EC2 Instance Failing To Start
2 min readJan 12, 2021
Your EC2 instance fails to start? Read here to fix it if it is a mount issue.
See the system log for errors:
Seeing volume mounting issues? It means you need to fix the /etc/fstab
using another machine. Follow these steps:
- Create a new machine with the same instance family you want to recover.
- Before starting the new machine, detach the root volume from the machine you want to recover and attach it to the new machine. Rename it in case you have the
/dev/sda1
in its Name tag (in AWS Console) to make sure AWS won’t attach it as a root volume to the new machine as well. - Start the new machine
- If it is not started (due to the same root volume conflict probably), try to snapshot the old root volume, then create a new volume out of it, and then attach the new one. Sometimes volumes get messed up and the snapshot trick will fix it.
lsblk
to see the name of the attached volumemkdir /mnt/recovered
mount -o nouuid /dev/nvme1n1p1 /mnt/recovered
The-o
here is to overcome the issue (mount: unknown filesystem type '(null)'
) of root volumes having the same UUIDcd /mnt/recovered/etc
vi fstab
- Add
,nofail
after thedefaults
. This will allow the old instance to start and for you to do the right thing and change your/dev/nvme2n1
with a proper UUID to prevent it to change after a restart (to get the UUID useblkid
). - Shutdown the new machine. Detach the recovered volume and attach it back to the original machine (make sure to name it
sda1
when prompted to be able to start it, otherwise you’ll get the “no root volume found” error). Start it. Done. You’ve saved the day :) - Remember to terminate the recovery machine $$
Best,