EC2 Instance starts and stops after attaching volume - amazon-web-services

I accidentally deleted the root volume and am trying to launch my instance. Upon creating a new volume I got an error saying: "Instance does not have a volume attached at root (/dev/sda1).
I attached a newly created volume to the instance with the volume id of /dev/sda1 and the instance successfully starts, is pending, and then stops, all with no system logs.
Any help is much appreciated.

Related

Why EC2 instance is stopping again and again?

I can't keep my EC2 instance in running state. Whenever I start the instance it always changing back to "Stopped" state. I tried many ways like they mentioned in this official page here.
Stopped and restarted the instance - didn't work
Created an alternate image of the current instance and launched a new instance with that image and started it. - didn't work
Finally, made a snapshot of current volume of stopped instance. Then created anew volume with that snapshot. Launched a new instance with a new AMI and stopped it. Then detached the root volume of new instance and attached the newly created volume as root volume. Then started the instance - didn't work though.
UPDATE: when I run below command to check the reason for the issue
aws ec2 describe-instances --instance-id MYINSTANCE --output json
it response with below issue
"StateReason": {
"Code": "Client.InstanceInitiatedShutdown",
"Message": "Client.InstanceInitiatedShutdown: Instance initiated shutdown"
},
What am I missing here?
You can try below
Create another fresh instance and ensure its working fine
Remove storage from this instance and attach it to the affected instance
Start your affected instance now which is having new latest storage (make sure to remove old storage)
If it works then it means there is some issue in the storage drive only.
If the above does not work then there is also possible some hardware issue. you can try creating same instance in different region with the same image to see if it works in different region or not.

How to decrease the AWS Windows EBS root volume?

I need to reduce my Windows EBS root volume.
We are able to increase the root volume by using AWS Console. So I have followed some document to decrease my Windows EBS root volume:
I created a new 30GB volume and attached it to my existing instance
I then used xcopy to copy the data from C:\ to D:\ which is newly attached volume
After completion of copying data, I then stopped the instance and detached both the EBS root volume and the newly added volume.
Then I reattached the newly created volume to the stopped EC2 instance as /dev/sda1
Now I am trying to start my Windows EC2 instance, but it fails to start. It is coming again and again to stopped state.
Note: I received error message like Sharing Violation after data copied.

Root Device and Block Devices difference

Can someone help me to understand the difference between Root device and Block devices for EC2 instance. You can see a snapshot i posted below.
What i tried to achieve is :
I created a snapshot of the attached volume of the EC2.
Detached the volume from instance.
Deleted the volume.
Created a new volume from the snapshot.
Reattached the newly created volume to the instance.
But it only attaches to the Block Devices but not to the root devices. And results in the failure to launch the instance.
My apologies if my question is wrong.
Awaiting your reply.
Thanks in advance.
The Root device is the EBS volume for the AMI in which your instance is based on. This will contain the operating system. If not configured then, AWS will use the default values of the AMI.
You can configure additional Block device entries optionally to mount additional volumes on the instance, besides the root volume. It can be empty or from a snapshot.

Changing Root EBS volume from Volume created from EBS Snapshot

I created snapshot, from volume(Root volume).
After one day, I need to set my snapshot as root volume.
I followed these steps :
For that I created a volume from snapshot.
My working instance was stopped.
Detached root volume of my instance
Attached the volume generated from snapshot as /dev/sda1
and then instance started
I have a problem while starting my instance, it was not starting and no errors occurred.
Can you guys please check the process and let me know if anything else required

EC2 Instance doesn't start after Reattaching the Volume

I'm trying to lunch an instance from backup snapshots.
I follow the procedure here :
Goto the snapshot section of the aws tools.
Create a volume from the snapshot.
Create an ec2 instance (make sure it's an EBS backed instance, if it's the same kind as the original snapshot you'll be fine)
Stop the instance
Detach the existing EBS volume from the instance
Attach the volume you just created, make sure you give it the same name as the instance that was attached.
Start the instance back up.
Not quite sure what is EBS backed instance.
Every thing works fine,But after I reattach the volume,The instance I created cant get start,when i press start,it pending for awhile then stopped again.
What maybe the problem?
Thanks in advance.
I also have done this before. It works. When you reattach the volume check the name, it should be identical to the original root volume name. If the root volume name is different it can't start.
This worked for me.
Basically the "Device" attachment information that is auto-populated wasn't right.
When I tried starting the EC2 instance the error read.
The error ,clearly states that volume isn't attached at(/dev/xvda)
Now, navigate back to volumes. Undo the previous attached volume.
Attach the volume again by providing the "Device" info as provided in the error message, /dev/xvda in this case.
Before detaching the volume, note down the volume id and device name which is actually mounted right now.
Then while reattaching another volume, you need to make above device name only otherwise it will not start.