Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I mount ephemeral storage on a windows ec2 instance using boto?

I have an AMI with Windows Server 2008 as an EBS root device. I can start it an instance using boto and remote desktop into it, but I cannot seem to get it mount its ephemeral storage. Is something wrong with my BlockDeviceMapping?

Here is my code:

import boto
from boto.ec2.connection import EC2Connection
conn = EC2Connection(mykey, mysecretkey)
bdm = boto.ec2.blockdevicemapping.BlockDeviceMapping({'/dev/xvdb':'ephemeral0'})
conn.run_instances(myami, key_name=mykeyname,security_groups=[mysecgroup],block_device_map=bdm)

When I run this code, an instance fires up and I can access, but I only see the root device mounted.

like image 745
oob Avatar asked Dec 01 '25 22:12

oob


1 Answers

I figured it out. I had seen some examples which led me to believe that the block device map should be a string to string map, but it should actually be a string to BlockDeviceType map. Here is how I got it to work:

from boto.ec2.connection import EC2Connection
from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
conn = EC2Connection(mykey, mysecretkey)
xvdb = BlockDeviceType()
xvdb.ephemeral_name='ephemeral0'
bdm = BlockDeviceMapping()
bdm['/dev/xvdb'] = xvdb
conn.run_instances(myami, key_name=mykeyname,security_groups=[mysecgroup],block_device_map=bdm)

When I logged in, I could see my ephemeral drive. Not that it does not show up in the AWS management console as a block device. You still only see your root device.

Here is a code sample / forum question that helped me figure it out.

like image 178
oob Avatar answered Dec 03 '25 11:12

oob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!