Recently, I needed to transform and migrate about 50GB of data stored in MongoDB. I needed to do it as quickly as possible to keep disruption to a minimum so I decided to try out Amazon's High I/O Instances, specifically the High I/O Quadruple Extra Large Instance (hi1.4xlarge) which provides two SSD-based volumes each with 1024 GB of storage and tons of CPU and memory. With these resources we estimated we could complete the migration in about 40 minutes versus 5 hours on the instance-type we normally use. Not a bad return for a cost of about $8 in usage fees.
Not long after booting up the instance I realised I had no idea how to find or use the ephemeral SSD volumes. They aren't formatted or mounted by default with most AMIs.New link
Here's what I did to make them available in what I think is the quickest and easiest way.
As you're going through the wizard to setup your EC2 instance with ephemeral storage, make a note of the device location for each of the ephemeral volumes. In this example below, the volumes will be presented as /dev/sdb and /dev/sdc.
- Finish the Request Instances Wizard and start the EC2 instance you just created and log on via SSH.
First, we need to create a file system on each volume. In this example, I've chosen EXT4.
sudo mkfs -t ext4 /dev/sdb
sudo mkfs -t ext4 /dev/sdc
Next we need to create a directory in which to mount the volumes this could be in /media or /mount or perhaps something application specific like /data or /log.
sudo mkdir /media/ephemeral0
sudo mkdir /media/ephemeral1
If you only temporarily need the volumes, as I did, you can simply mount them and use them:
sudo mount -t ext4 /dev/sdb /media/ephemeral0
sudo mount -t ext4 /dev/sdc /media/ephemeral1
Or, to automatically mount the ephemeral volumes at boot (you may be creating a custom AMI, for example) you would add a line for each volume to your /etc/fstab:
/dev/sdb /media/ephemeral0 ext4 defaults 1 2
/dev/sdc /media/ephemeral1 ext4 defaults 1 2
And then manually mount the volumes (or reboot):