Attach a Persistent EBS Volume to an Instance

You are storing data on an EC2 instance and you would like that data to persist even if the instance fails.

Use the create_volume method and other EBS-related methods to create a volume and attach it to an existing instance.

All EC2 instances have a root volume associated with them. This is where the operating system is installed. The size of this root volume depends on how the image was bundled and whether the corresponding AMI is S3-backed or EBS-backed.

In addition, all EC2 instance types except the t1.micro have dedicated instance storage. The number of volumes and total amount of instance storage varies depending on the instance type, but all instance storage has one property in common: it is ephemeral. When you terminate the instance (or when it fails for some reason), all of the instance storage goes away and anything you have stored there will be lost.

To provide persistent storage (that is, storage that exists independent of an instance), EC2 provides Elastic Block Storage (EBS). EBS allows you to create volumes of any size (from 1 GB to 1 TB) and attach the volumes to any EC2 instance. If that instance fails for any reason, the volume can be reattached to a replacement instance and the data will then be available to that new instance.

EBS volumes have about the same reliability you would expect from a RAID device, so while failures are not common, they can happen. We will discuss ways to back up your EBS volume in Back Up Your EBS Volumes.