299

I am trying to stop a Amazon EC2 instance and get the warning message

Warning: Please note that any data on the ephemeral storage of your instance will be lost when it is stopped.

My Question

What data is stored in ephemeral storage of an Amazon EC2 instance?

Alberto Zaccagni
  • 28,473
  • 10
  • 71
  • 102
Gaurav Agarwal
  • 17,165
  • 28
  • 97
  • 157

5 Answers5

269

Basically, root volume (your entire virtual system disk) is ephemeral, but only if you choose to create AMI backed by Amazon EC2 instance store.

If you choose to create AMI backed by EBS then your root volume is backed by EBS and everything you have on your root volume will be saved between reboots.

If you are not sure what type of volume you have, look under EC2->Elastic Block Store->Volumes in your AWS console and if your AMI root volume is listed there then you are safe. Also, if you go to EC2->Instances and then look under column "Root device type" of your instance and if it says "ebs", then you don't have to worry about data on your root device.

More details here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html

atilacamurca
  • 168
  • 1
  • 10
  • 12
nidalpres
  • 3,538
  • 1
  • 16
  • 12
  • 101
    This probably wouldn't confuse people so much, if AWS wasn't giving the unnecessary warning message "that any data on the ephemeral storage of your instance will be lost" even when attempting to stop an instance, that IS using an EBS backed root device, and there is actually no reason to worry about any data loss. – Tilman Mar 14 '14 at 19:36
  • 2
    the warning applies because you can have both an BS backed root AND an ephemeral storage attached (manually as aws doesnt do so by default) – Zig Mandel Jun 05 '14 at 22:18
  • Actually, I just went ahead and did this but there was an error anyway: `Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346` Any ideas? This wasn't happening prior to doing this. – James Sep 11 '14 at 00:50
  • Just to follow up, for some reason `mysqld` service stopped running. Support said this is not normal, but that was the only issue. – James Sep 11 '14 at 02:25
  • 3
    @Tilman Exactly what I was thinking. The warning is not only unnecessary, it is misleading as well. Thanks for pointing it out. – Sabuncu Dec 13 '14 at 15:04
  • '... under column "Root device type" ' . The correct name of the column is root device type. – thanos.a Apr 02 '17 at 19:05
  • @ZigMandel actually Amazon could easily program AWS to check the volumes attached to the instance and display this message *only* when an ephemeral storage volume is attached. If all storage volumes are EBS, it could hide the message away or even display a "Don't worry, your data is safe" message... But the lazy programmers at Amazon decided to just slap everyone with the same scary message, regardless of there is anything real to be scared of or not. – ADTC Apr 11 '17 at 14:10
  • Keep in mind that NVMe SSD volumes are going to be lost when the instance is stopped: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssd-instance-store.html The data on NVMe instance storage is encrypted using an XTS-AES-256 block cipher implemented in a hardware module on the instance. The encryption keys are generated using the hardware module and are unique to each NVMe instance storage device. All encryption keys are destroyed when the instance is stopped or terminated and cannot be recovered. You cannot disable this encryption and you cannot provide your own encryption key. – Maciej Łopaciński Nov 19 '18 at 15:35
152

Anything that is not stored on an EBS volume that is mounted to the instance will be lost.

For example, if you mount your EBS volume at /mystuff, then anything not in /mystuff will be lost. If you don't mount an ebs volume and save stuff on it, then I believe everything will be lost.

You can create an AMI from your current machine state, which will contain everything in your ephemeral storage. Then, when you launch a new instance based on that AMI it will contain everything as it is now.

Update: to clarify based on comments by mattgmg1990 and glenn bech:

Note that there is a difference between "stop" and "terminate". If you "stop" an instance that is backed by EBS then the information on the root volume will still be in the same state when you "start" the machine again. According to the documentation, "By default, the root device volume and the other Amazon EBS volumes attached when you launch an Amazon EBS-backed instance are automatically deleted when the instance terminates" but you can modify that via configuration.

Jude Niroshan
  • 3,973
  • 6
  • 36
  • 53
digitaljoel
  • 25,150
  • 14
  • 83
  • 114
  • Can you help me with how can I see the content of ephemeral storage at any point in time? – Gaurav Agarwal Jul 19 '12 at 17:49
  • 2
    everything on the instance would be in ephermeral storage unless you have configured and mounted an ebs volume and are consciously putting your data on it. – digitaljoel Jul 19 '12 at 17:53
  • Everything in / is Ephemeral storage, including the mounted device /mnt. If you want persistant storage you must create a new ebs volume and mount it to a location, and move the data you want to retain to that. – Kevin Willock Jul 21 '12 at 02:17
  • 2
    Does this only apply to `instance store` devices? That is, on an `ebs` device, is my root storage drive ephemeral or not? – Dean Oct 23 '12 at 23:49
  • 18
    This answer is not exactly correct, where your data is stored depends on what type of AMI you chose to create. The below answer by @nidalpres is more complete. If you chose to create an AMI backed by EBS, then your root directory is NOT stored in ephemeral storage. – mattgmg1990 Oct 09 '13 at 21:57
  • @mattgmg1990 You are correct, thanks. I have updated the answer to more properly spell that out. – digitaljoel Oct 09 '13 at 22:58
  • 1
    I would just like to add that I think that @nidalpres wrote a better answer, or at the very least one that is a lot easier to grasp. – Lozzano Oct 17 '13 at 17:04
  • Is this still true? "The data in an instance store persists only during the lifetime of its associated instance. If an instance reboots (intentionally or unintentionally), data in the instance store persists." From: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html – Francesco Frapporti Dec 15 '14 at 22:33
  • rebooting is still within the "lifetime of its associated instance." It's when you "terminate" that the instance life is... terminated. – digitaljoel Dec 16 '14 at 00:07
  • @digitaljoel Does the snapshot automatically gets updated when I add new data to my instance? – Suhail Gupta Jan 08 '16 at 11:16
  • Snapshots are just a snapshot in time, so if you want more data in your snapshot then you'll have to create a new snapshot. – digitaljoel Jan 08 '16 at 15:59
  • 1
    "If you "terminate" the machine, then even if it is backed by EBS it is gone." This is not correct. This is determined by the flag "Delete on Termination" on the "add storage" page (referring to the root volume). It can also be specified on the command line, and even changed on running instances using the CLI (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html#choose-an-ami-by-root-device) – Glenn Bech Sep 28 '16 at 19:27
  • This is good info Glenn. It was true when I wrote the answer over 4 years ago, but sounds like it is not true now. – digitaljoel Sep 29 '16 at 02:47
7

To be clear and answer @Dean's question: EBS-type root storage doesn't seem to be ephemeral. Data is persistent across reboots and actually it doesn't make any sense to use ebs-backed root volume which is 'ephemeral'. This wouldn't be different from image-based root volume.

januszm
  • 1,057
  • 13
  • 20
  • 2
    All EBS-backed storage is persistent, eg non-ephemeral, after you "Stop" the instance. If you "Terminate" you will lose the data. Please see http://stackoverflow.com/a/11566285/46249. – Matthew Jan 14 '15 at 20:12
0

According to AWS documentation [https://aws.amazon.com/premiumsupport/knowledge-center/instance-store-vs-ebs/] instance store volumes is not persistent through instance stops, terminations, or hardware failures. Any AMI created from instance stored disk doesn't contain data present in instance store so all instances launched by this AMI will not have data stored in instance store. Instance store can be used as cache for applications running on instance, for all persistent data you should use EBS.

0

ephemeral is just another name of root volume when you launch Instance from AMI backed from Amazon EC2 instance store

So Everything will be stored on ephemeral.

if you have launched your instance from AMI backed by EBS volume then your instance does not have ephemeral.

Ravindra Bagale
  • 16,225
  • 9
  • 38
  • 68