Are files stored on an EBS volume? Shouldn't they be saved? I'm confused

So, I create an instance using one of the public AMI EBS Ubuntu flavors. I create an EBS volume and attach it to the instance. I will format the volume and add an entry to / etc / fstab to set it to / vol. I add mysql to AMI and move the data files to the EBS that I formatted and mounted in / vol. Then I create the AMI from the executable instance. Then I complete the executable instance.

I am starting a new instance using the newly created AMI (with mysql on it). Is installed / vol, has mysql data files - well, I expect this. Here where I am confused. When I create any directory or files in the / vol EBS volume, they no longer exist after the instance is completed and a new one is created. There is mysql stuff here, but I have not created new stuff. Shouldn't these files and directory be there? Or do I not understand how this works?

+6
source share
2 answers

When you create an AMI, "Amazon EC2 shuts down the instance, takes images of any volumes that were attached, creates and registers the AMI, and then reloads the instance." -Amazon. When AMI is used to start an instance, images (snapshots) of mapped drives are used to create new volumes. It is these new volumes that are attached to the new copy, and not to your original EBS. (This creates many volumes and orphans with constant use.)

Automatically add the volume of EBS that you created. What is automatically added is the one that it creates when the instance starts from your AMI! He creates this volume from a snapshot taken by your EBS during the creation of AMI!

The way to avoid creating clone volumes and connecting them to new instances is simple: detach your volumes before creating the AMI. You need to attach your EBS volumes manually using the EC2 web control panel or programmatically using .net or Java programs, scripts, or command line tools.

+2
source

EBS volumes are not tied to AMI, only to the literal instance to which you are attaching. When you create your AMI and a new instance, EBS does not clone and does not follow you in the new instance.

You can transfer the EBS disk to a new instance manually. Alternatively, you can take a snapshot of the EBS volume and clone the new disk.

+1
source

Source: https://habr.com/ru/post/918318/


All Articles