AWS EC2 – Attach Larger Volume with run-instances

Question:

I’m having difficulty launching an EC2 instance and increasing the size of the root partition in a single command with aws ec2 run-instances:

The instance launches, and I can see the new 120GB volume listed (though not as root) in the console, but then the instance immediately stops (not terminates). I’ve tried renaming the DeviceName property per these conventions, This is a temporary instance that I’m going to launch, do stuff, then terminate. Maybe I need to run create-volume first and then attach it with a separate series of commands? The AWS documentation seems to be all over the place on this and I can’t find a clear explanation, though I’ve come across a few links here and here. This SO question suggests resizing the partition but I’m not sure if that’s what I need to do. As far as I can tell, the m3.2xlarge instance type has EBS available. Am I naming the partition incorrectly? Is something in this configuration causing the stoppage of the instance?

EDIT

After the instance stops itself, I get the follow as part of the response to describe-instances:

Answer:

I think you’re running into the same problem that this SO question is having:

https://serverfault.com/questions/615188/aws-t1-to-t2-migration-client-instanceinitiatedshutdown-on-new-t2-instance

Your instance is an HVM instance and wants to use /dev/xvda as the root device. However, you’re specifying /dev/sda1. This is (a) creating a secondary volume instead, but then (b) preventing the instance from launching because that’s a PV-related device rather than HVM.

So, as a solution, use /dev/xvda as the device name instead. Like the following command line:

Leave a Reply