Skip to content

EBS Icon-Architecture/64/Arch_Amazon-Elastic-Block-Store_64Created with Sketch.

What is block storage?

When you're using Amazon EC2 to run your business applications, those applications need access to CPU, memory, network, and storage. EC2 instances give you access to all those different components, and right now, let's focus on the storage access. As applications run, they will oftentimes need access to block-level storage.

You can think of block-level storage as a place to store files. A file being a series of bytes that are stored in blocks on disc. When a file is updated, the whole series of blocks aren't all overwritten. Instead, it updates just the pieces that change. This makes it an efficient storage type when working with applications like databases, enterprise software, or file systems.

When you use your laptop or personal computer, you are accessing block-level storage. All block-level storage is, in this case, is your hard drive. EC2 instances have hard drives as well. And there are a few different types.

When you launch an EC2 instance, depending on the type of the EC2 instance you launched, it might provide you with local storage called instance store volumes. These volumes are physically attached to the host, your EC2 instances running on top of. And you can write to it just like a normal hard drive. The catch here is that since this volume is attached to the underlying physical host, if you stop or terminate your EC2 instance, all data written to the instance store volume will be deleted. The reason for this, is that if you start your instance from a stop state, it's likely that EC2 instance will start up on another host. A host where that volume does not exist. Remember EC2 instances are virtual machines, and therefore the underlying host can change between stopping and starting an instance.

  • We can think them of to be like virtual hard drives
  • They can only be used with EC2.
  • Can only be tied to single AZ
  • Officially, instances can have up to 28 EBS attachments. One of those attachments is the network interface attachment, leaving 27 attachments available for EBS volumes. However, the better approach is to remember that an instance can attach to a root volume and several more volumes (more than two).
  • EBS volumes store data within a single Availability Zone. Amazon EFS file systems store data across multiple Availability Zones.

As shown in the image below, the EC2 instance storage is locked to EC2 instance while EBS are not locked to an EC2. We can also create snapshot from EBS

!!! question 'Why do we need snapshots?' - Cost effective backup stragegy - To share data-sets with others users/accounts - Migrate a system to new AZ/Region - They are used to convert unencrypted volume to an encrypted one

Each EBS is replicated in itโ€™s AZ by default.

Encryption

  • EBS volumes can be encrypted when they are created.
  • You cannot encrypt an existing EBS volume โ€œon the fly.โ€ You must create a snapshot and then encrypt that snapshot as you copy it to another, encrypted snapshot. You can then restore from that new snapshot.

What all is encrypted in EBS?

There are four types of data encrypted when an EBS volume is encrypted:

- Data at rest on the volume.
- Data moving between the volume and the instance.
- Any snapshots created from the volume.
- Any volumes created from those snapshots.

Points to remember

  • You must make a copy of an unencrypted snapshot to apply encryption.
  • You cannot encrypt an existing EBS volume.
  • You cannot encrypt a snapshot that is unencrypted.
  • You can encrypt a copy of a snapshot and restore an encrypted snapshot to a volume that is encrypted.

Different types of EBS

  • General-purpose SSD
  • Provisioned IOPS SSD
  • Throughput optimized HDD
  • Cold HDD: Cold HDD is the lowest cost HDD
  • EBS magnetic HDD

EBS Backup/Snapshot

Take backup of EBS

Since the use case for EBS volumes is to have a hard drive that is persistent, that your applications can write to, it's probably important that you back that data up. EBS allows you to take incremental backups of your data called snapshots. It's very important that you take regular snapshots of your EBS volumes This way, if a drive ever becomes corrupted, you haven't lost your data. And you can restore that data from a snapshot.

An EBS snapshot is an incremental backup. This means that the first backup taken of a volume copies all the data. For subsequent backups, only the blocks of data that have changed since the most recent snapshot are saved.

Move the EBS from one AZ to another

Option A

  • creates a snapshot from a volume.
  • create an AMI from a snapshot.

Option B

  • Copy the AMI to a different region. Then go to that region and choose the AZ AZโ€™s can be changed when we choose from the subnets

Types of root volumes

2 types of root volumes are there:

  1. Instance storage : They are called Ephemeral storage as we are going to lose all the data if itโ€™s stopped. They can not be stopped.
  2. EBS backed: they can be stopped, they are persisted as well.

Remember

By default, root volumes do get deleted when the associated instance terminates. However, you can configure this to not be the case.

  • We can create AMI from both snapshots and volumes.
  • For an EBS volume that is used as a root volume, if you want to take a consistent - snapshot then stop the instance as it is writing the data to EBS.
  • ENI (Elastic Network Interface):
  • EN (Enhanced Networking): This has a high speed of 100 Gbps and is used for high - performance. It uses the ENA (Enhanced network adapter).
  • EFA (Elastic Fiber Adapter): use for HPC and ML.

Warning

  • If we close the instance, then the root volume is deleted but the persisted data - remains.
  • Volumes exist on EBS whereas the snapshots exist on S3
  • Snapshot is a delta (incremental). Taking the first snapshot may take a lot of time.
  • We can change the EBS volume size on the fly.
  • Volumes are always in the same AZ as the instance is.
  • We can create AMI from snapshots.
  • Move EC2 to at new AZ
  • take a snapshot โ†’ to create AMI โ†’ use AMI to launch in new AZ
  • Move EC2 to a new region
  • Take a snapshot โ†’ to create AMI โ†’ copy AMI to new region โ†’ use AMI to launch in new - AZ

Was this page helpful?
-->