What data is stored in Ephemeral Storage of Amazon EC2 instance?
Asked Answered
B

7

307

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?

Babel answered 19/7, 2012 at 17:31 Comment(0)
E
156

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.

Erythrism answered 19/7, 2012 at 17:35 Comment(13)
Can you help me with how can I see the content of ephemeral storage at any point in time?Babel
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.Erythrism
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.Indophenol
Does this only apply to instance store devices? That is, on an ebs device, is my root storage drive ephemeral or not?Phoneme
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 @Supplicant is more complete. If you chose to create an AMI backed by EBS, then your root directory is NOT stored in ephemeral storage.Shaunna
@Shaunna You are correct, thanks. I have updated the answer to more properly spell that out.Erythrism
I would just like to add that I think that @Supplicant wrote a better answer, or at the very least one that is a lot easier to grasp.Ernst
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: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…Atahualpa
rebooting is still within the "lifetime of its associated instance." It's when you "terminate" that the instance life is... terminated.Erythrism
@Erythrism Does the snapshot automatically gets updated when I add new data to my instance?Necktie
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.Erythrism
"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 (docs.aws.amazon.com/AWSEC2/latest/UserGuide/…)Hackworth
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.Erythrism
S
278

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

Supplicant answered 11/4, 2013 at 2:44 Comment(8)
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.Kimberleekimberley
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)Gradation
Just to follow up, for some reason mysqld service stopped running. Support said this is not normal, but that was the only issue.Holcomb
@Kimberleekimberley Exactly what I was thinking. The warning is not only unnecessary, it is misleading as well. Thanks for pointing it out.Ashti
'... under column "Root device type" ' . The correct name of the column is root device type.Title
@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.Melva
Keep in mind that NVMe SSD volumes are going to be lost when the instance is stopped: docs.aws.amazon.com/AWSEC2/latest/UserGuide/… 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.Pokeweed
Even though data is completely gone from ephemeral disk on hardware crash / instance stop, there is a huge difference in speed: gist.github.com/ktheory/3c3616fca42a3716346b Ephemeral storage is 5x-10x faster than EBS. Using Lsyncd, Csync2, rsync, etc one could sync mysql's data directory or apache's web directory from ephemeral to an EBS disk. Please test heavily before production. See n2ws.com/blog/aws-ec2-backup/… and icicimov.github.io/blog/devops/… Again, test heavily first.Donalt
E
156

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.

Erythrism answered 19/7, 2012 at 17:35 Comment(13)
Can you help me with how can I see the content of ephemeral storage at any point in time?Babel
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.Erythrism
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.Indophenol
Does this only apply to instance store devices? That is, on an ebs device, is my root storage drive ephemeral or not?Phoneme
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 @Supplicant is more complete. If you chose to create an AMI backed by EBS, then your root directory is NOT stored in ephemeral storage.Shaunna
@Shaunna You are correct, thanks. I have updated the answer to more properly spell that out.Erythrism
I would just like to add that I think that @Supplicant wrote a better answer, or at the very least one that is a lot easier to grasp.Ernst
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: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…Atahualpa
rebooting is still within the "lifetime of its associated instance." It's when you "terminate" that the instance life is... terminated.Erythrism
@Erythrism Does the snapshot automatically gets updated when I add new data to my instance?Necktie
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.Erythrism
"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 (docs.aws.amazon.com/AWSEC2/latest/UserGuide/…)Hackworth
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.Erythrism
U
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.

Unworldly answered 6/1, 2013 at 12:55 Comment(1)
All EBS-backed storage is persistent, eg non-ephemeral, after you "Stop" the instance. If you "Terminate" you will lose the data. Please see https://mcmap.net/q/99435/-what-data-is-stored-in-ephemeral-storage-of-amazon-ec2-instance.Jewess
B
1

For EC2 instance

Stop & Start != Reboot

so for ephemeral storage (Instance Store) Stop cause data lost Reboot will not

Benthamism answered 5/6, 2022 at 14:58 Comment(0)
E
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.

Epicurean answered 27/3, 2018 at 9:45 Comment(0)
C
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.

Clareta answered 9/10, 2020 at 10:18 Comment(0)
O
0

refer: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html#instance-store-volumes

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. However, 
data in the instance store is lost under any of the following
 circumstances:

- The underlying disk drive fails

- The instance stops

- The instance hibernates

- The instance terminates
Ontina answered 3/2, 2023 at 1:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.