Notes for mounting Amazon EBS block device


I needed a disk that is around 1 TB for testing on Windows 2008, and noticed that EC2 Extra Large Instance (API name m1.xlarge) satisfies that requirement. But after launching it via AWS Management Console and remote into the server, I noticed I only got 30 GB, far less than the 1690 GB that was promised. The ensuing search convinced me that I needed to use Amazon EC2 API Tools, which is a set of command line tools available for download. I’ve done that before but had to search again because it is a while ago. This time I got a bit smarter, I took some notes!

1. Download and setup the command line tools:
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?setting-up-your-tools.html
a. $PATH needs to have path to ec2 command line bin
b. Recreated my X.509 Certificate and private key pair. This is done via AWS Management Console -> Account (link in the middle of the top line) -> Security Credentials
c. Setup the certificate and private key pair environmental variables
d. Configure and setup $JAVA_HOME sine the tools need Java

2. Browse through AWS Management Console and copy down the AMI ID you are interested in
a. 3 things to filter: Image source and type, Operating System, ad-hoc string filtering. In my case, I did “All Images”, “Windows”, and “2008”. I am interested in ami-d9e40db0
b. Inside the AWS Management Console web interface, once the AMI is selected, a bottom pane will display some metadata. For disk size, pay attention to Block Devices. In my case, it says “Block Devices: /dev/sda1=snap-289c2740:30:true”. I’d like that 30 to be 1690, the size of “Extra Large Instance”. For that, you will have to do it via the command line.

Alternatively, we can get that infor via command line:
[sourcecode language=”text”]
ec2-describe-images ami-d9e40db0
[/sourcecode]

3. So I did:

[sourcecode language=”text”]
ec2-run-instances ami-d9e40db0 –b “/dev/sda1=snap-289c2740:1690:true” -g ec2windows -k HaidongKey
[/sourcecode]

and got the message below:

[sourcecode language=”text”]
Client.InvalidParameterValue: The requested instance type’s architecture (i386) does not match the architecture in the manifest for ami-d9e40db0 (x86_64)
[/sourcecode]

Thanks to web search, it turns out I needed to specify the type m1.xlarge:

[sourcecode language=”text”]
haidong@haidong-laptop ~ $ ec2-run-instances ami-d9e40db0 –b “/dev/sda1=snap-289c2740:1290:true” -g ec2windows -t m1.xlarge -k HaidongKey
RESERVATION r-87856fed 436613090425 ec2windows
INSTANCE i-30ae415d ami-d9e40db0 pending 0 m1.xlarge 2010-10-09T04:36:37+0000 us-east-1a windows monitoring-disabled ebs hvm
[/sourcecode]

But I was not out of the woods yet. See below:

[sourcecode language=”text”]
haidong@haidong-laptop ~ $ ec2-describe-instances
RESERVATION r-87856fed 436613090425 ec2windows
INSTANCE i-30ae415d ami-d9e40db0 terminated 0 m1.xlarge 2010-10-09T04:36:37+0000 us-east-1a windows monitoring-disabled ebs hvm
[/sourcecode]

I tried various ways before I decided to ask on Amazon’s cloud computing forum, and got it answered in an hour or so. It turns out for the EBS volume the maximum is 1024.

So I tried this:

[sourcecode language=”text”]
ec2-run-instances ami-d9e40db0 –b “/dev/sda1=snap-289c2740:1000:true” -g ec2windows -t m1.xlarge -k HaidongKey
[/sourcecode]

And it worked:

[sourcecode language=”text”]
haidong@haidong-laptop ~ $ ec2-describe-instances
RESERVATION r-fd639397 436613090425 ec2windows
INSTANCE i-bc23d2d1 ami-d9e40db0 ec2-184-72-199-184.compute-1.amazonaws.com ip-10-122-87-151.ec2.internal running HaidongKey 0 m1.xlarge 2010-10-12T01:40:31+0000 us-east-1a windows monitoring-disabled 184.72.199.184 10.122.87.151 ebs hvm
BLOCKDEVICE /dev/sda1 vol-4a8d8923 2010-10-12T01:40:36.000Z
[/sourcecode]

It takes a few minutes to get Administrator’s password. Unlike the message provided at AWA Management Console web interface, you get the message below before it is ready:

[sourcecode language=”text”]
haidong@haidong-laptop ~ $ ec2-get-password i-bc23d2d1 -k HaidongKey_unix.pem
No element was found for this instance.
[/sourcecode]

After I got the password:
[sourcecode language=”text”]
haidong@haidong-laptop ~ $ ec2-get-password i-bc23d2d1 -k HaidongKey_unix.pem
E)yX=nTX!D
[/sourcecode]
and logged in, the disk still shows as 30 G. Got to go to disk manager in Windows to mount it.

Hope this helps somebody. I certainly will know what I need to do next time.


2 responses to “Notes for mounting Amazon EBS block device”

  1. I am trying to use the ec2-get-password as well. I keep receiving an error that there is No element was found for this instance. I read it takes a while to retrieve the password. However, my command line almost immediately replies with this message. I am still looking into other ways to retrieve password. I really need it because when I setup a vnc server or nx server, it keeps messing up my ssh key login.

  2. Sounds like a tool setup problem, Drew. Currently I am not using Amazon’s clouds that much, I’ve been using Rackspace’s cloud and am reasonably pleased so far. If I encounter similar things with Amazon EC2 in the future, I will be sure to share that with you via email and comment here.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.