How to access instance storage on a Windows EC2 instance with an ebs root device

amazon ec2amazon-ebsamazon-web-services

I have created an AMI, but I would like to use instance storage for some scientific programs I want to run. They basically read a bunch of stuff from disk, write it back out to disk and then summarize those results. This needs to be on Windows because that is the platform these programs were written for. I don't need to the files to persist and I don't really care if I lose them, so I would like to use instance storage for this and not incur any fees for I/O.

So, I boot up my AMI, but when I remote in, I only see my EBS root device. How can I mount the instance (ephemeral) storage that is available to me?

Best Answer

While all instances, other than the t1.micro, do have an allocation of 'instance storage' (i.e. ephemeral storage), that storage is not necessarily attached by default. In most cases, instances with an EBS root volume will have zero or one attached ephemeral volumes.

The ephemeral disks, available to an instance are labelled ephemeral[0-3]. You can NOT attach these to an instance once it has been launched. (On the other hand, you can add EBS volumes to an instance while it is running).

Since ephemeral disks, together with EBS volumes, are block devices, AWS calls the mapping of these disks to an instance's devices 'block device mappings', and these can be specified either using the -b or --block-device-mapping parameters (which you can use more than once).

In order to change the ephemeral disks attached to the instance, you need to either:

  1. launch the instance explicitly specifying the ephemeral disk mappings OR

    ec2-run-instances ami-xxxxxxxx -b /dev/xvdb=ephemeral0 -b /dev/xvdc=ephemeral1 -b /dev/xvdd=ephemeral2 -b /dev/xvde=ephemeral3
  2. register a new AMI, explicitly specifying the ephemeral disk mappings (and an EBS root):

    ec2-register -n Image_Name -d Image_Description --root-device-name /dev/xvda1 -b /dev/xvda1=snap-xxxxxxxx -b /dev/xvdb=ephemeral0 -b /dev/xvdc=ephemeral1 -b /dev/xvdd=ephemeral2 -b /dev/xvde=ephemeral3

Note, on windows instance, you will specify the device as /dev/xvdX, whereas on Linux instances you will specify it as /dev/sdX (although, modern Linux kernels will still show this device as /dev/xvdX, with a symlink to /dev/sdX). Additionally, Windows instances will format the instance store volumes to NTFS (although, by default, the volumes come formatted as ext3).

AWS details the available instance storage and allocations in their documentation.