Storing data persistently with Amazon

Author:Rosangela Canino-Koning
Date:June 7, 2010

If you want to save your data across instances – that is, if you want to have persistent data – Amazon can do that for you, too. You need to use the Amazon Elastic Block Storage service, which creates a virtual hard drive that you can (virtually) attach to your EC2 instance.

Note that EBS charges you based partly on how much disk space you use per month, rather than on connectivity or anything else, so even if you don’t have an EC2 machine running, you’ll be paying Amazon for data storage.

You can read more about EBS here.


This tutorial assumes you’ve already set up an account on Amazon Web Services, and that you’ve completed the EC2 tutorial to set up an Amazon instances.

Ask Amazon to create a new Elastic Block Storage Volume for you

At the AWS Management Console, on the left menu bar, click “Volumes”.


Click “Create Volume”.


Enter the desired size, and select the zone in which your instance is running. The volume and instance must be in the same zone. Otherwise, the volume cannot be attached to your instance.

Then click “Create”.


Wait for your volume to finish being created, then click “Attach Volume”.


Select the desired running instance. You may leave the Device at the default: /dev/sdf. This is the name that your EC2 instance can use to connect to the disk space

Click “Attach”.


When attachment is complete, connect to your instances via SSH.

If the volume is newly created, you must format the volume. WARNING: ONLY DO THIS ONCE, WHEN YOU FIRST CREATE THE VOLUME. OTHERWISE, YOU WILL LOSE ALL YOUR DATA.

%% mkfs -t ext2 /dev/sdf

It will ask you if you want to use the entire device – say “y” for “yes.

Then, mount the volume. You’ll do this every time you attach the volume to an instance:

%% mkdir /mnt/ebs
%% mount /dev/sdf /mnt/ebs

Your drive is now ready to use – it will be available under /mnt/ebs.

Shutting down your instance

Any volumes you have attached will automatically detach when you shut down the instance. You can also stop all processes that are using the volume, change out of the directory, and type

%% umount /mnt/ebs

and then detach the volume via the AWS Web site.

LICENSE: This documentation and all textual/graphic site content is licensed under the Creative Commons - 0 License (CC0) -- fork @ github. Presentations (PPT/PDF) and PDFs are the property of their respective owners and are under the terms indicated within the presentation.
comments powered by Disqus