Chapter-4 EC2 EBS

Amazon EBS is like a hard drive in the cloud that gives persistent block storage volumes for use with Amazon EC2 instances.

EBS volumes can be attached to EC2 instances and we can create a file system on top of these volumes. In this chapter, we will learn about EBS Volumes.

Areas to be covered:

*What is EBS?
* What are the different types of EBS Storages?
* What is Difference between these EBS Volume types?
* What are Methods of Creating a Volume?
*Suppose we have to move Volumes in different Availability zones i.e. us-west-1c.How will we do it?
*If User terminates EC2 instance, will all Volumes linked to that EC2 deleted?
*How to delete Snapshot?
*Difference between EBS and Instance Store?
*How can we encrypt Root Device Volume?

What is EBS?

Amazon Elastic Block Store (EBS) provides persistent block storage volumes for use with Amazon EC2 instances in the AWS Cloud.

Each Amazon EBS volume is automatically replicated within its Availability Zone to protect you from component failure, offering high availability and durability.

We can use EBS volumes as primary storage for data that requires frequent updates.After a volume is attached to an instance, we can use it like any other physical hard drive. EBS volumes are flexible.

If we delete any EC2 instance, then volumes attached to respective EC2 instance will be deleted.

What are the different types of EBS Storages?

Ans-There are 5 Different Types of EBS Storage:

General Purpose (SSD)

Provisioned IOPS (SSD)

Throughput Optimized Hard Disk Drive

Cold Hard Disk Drive

Magnetic

Difference between these EBS Volume types:

Now we will learn about EBS Volume creation.

Methods of Creating a Volume

  1. Create and attach EBS volumes when you launch instances by specifying a block device mapping.
  2. You can restore volumes from previously created snapshots.
  3. Create an EBS volume and attach it to a running instance.

Let’s learn Method 1 now. Remaining methods will be discussed later.

Method 1: Create and attach EBS volumes when you launch instances by specifying a block device mapping.

Step 1:

Open the Amazon EC2 console 

AND Create an EC2 Instance (follow steps 1 to 6 in EC2 Creation -Chapter 1).

Step 2:

Add Storage

We can select storage type of any volume type. Even we can provide Storage size based on our needs. By Clicking on ADD NEW VOLUME new Volume type can be added.

Step 3: Fill next steps and launch EC2 instance.

Step 4: Navigate to Volumes tab and verify added Volumes:

Now we can modify Volumes size as per requirement.

Consider we have to increase size of io1 Volume type then navigate to Actions->Modify Volume.

And perform actions.







Once we modify volumes size , we get info saying that – it will take sometimes to reflect its changes.

Now refresh page and check whether size got increased or not.

So we have created EBS Volumes during launching EC2 Instance.

Q) Suppose we have to move Volumes in different Availability zones i.e. us-west-1c. How will we do it?

Solution: There are two ways to solve this problem.

Way 1:

Step 1: Create Snapshot first.

Note: Snapshot is photocopy of disk. In details,

An EBS snapshot is a point-in-time copy of your Amazon EBS volume, which is lazily copied to Amazon Simple Storage Service. EBS snapshots are incremental copies of data. This means that only unique blocks of EBS volume data that have changed since the last EBS snapshot are stored in the next EBS snapshot.

Navigate to Volumes and click on Actions->Create Snapshot





Snapshot is created and we can see created snapshot under snapshot.


Step 2: Now we will create Image which will be deployed in different Availability zone:




We can see created Images under AMIs tab.


Step 3: Now click on Launch and create EC2 instance.

A screenshot of a social media post

Description automatically generated


Next:

Change the subnet level in different Availability zone:

In this way, we can move Volumes in different AZ.

Now continue remaining steps and Launch EC2 instance.

A screenshot of a social media post

Description automatically generated

A screenshot of a cell phone

Description automatically generated




We can see, One EC2 instance is created in different zone i.e in us-west-1c.

Way 2:

Other ways, we can copy AMI image in different region.

Navigate to AMIs and then navigate to Actions->Copy AMI





We can change Destination region based on our requirement. In this way, EC2 instance from 1 region to another region is copied.

So we have discussed both ways to move Volumes in different AZ.

Post this lab , lets delete all EC2, Volumes ,Snapshots and images.

Q) If User terminates EC2 instance, will all Volumes linked to that EC2 deleted?

Ans- No. Lets understand in this way. We have terminated EC2 instance.

Lets navigate to Volumes and check whether all volumes are deleted or not.



Additional Volumes will not be deleted, which is added while EC2 creation. We have to delete Additional Volumes manually.

Now delete all volumes.





All volumes will be deleted.

Q) How to delete Snapshot?

Navigate to Snapshot and delete.





Before deleting Snapshot, we must delete AMIs images.

Navigate to AMIs -> images and delete images.



Now we can delete Snapshot.

********************************************************************************************

Difference between EBS and Instance Store:

As we know that we can select AMI based on below parameters:

  1. Region (Regions and Availability Zones)
  2. Operating system
  3. Architecture
  4. Launch Permissions
  5. Storage for the Root Device

  There are 2 types of Storage for the Root Device

a) Instance Store

b) EBS Backed Volumes

For Instance Store Volumes: An instance launched from the AMI is an instance store volume if it is created from a template (stored in Amazon S3).

For EBS Volumes: An instance launched from the AMI is an Amazon EBS volume if it is created from an Amazon EBS snapshot.

Lets practice this.

Step 1: Create EC2 instance following steps defined in Chapter 1-EC2 instance creation.

A screenshot of a social media post

Description automatically generated

Step 2: Create 2nd instance – Click on Community AMIs and select EBS  UNDER Root device type.






Next Add Storages


Complete remaining steps and launch Instance.

This instance cannot be stopped.


Now we can terminate all Instances.

************************************************************************

How can we encrypt Root Device Volume?

We can encrypt Root Device Volume in following ways:

Step 1: Launch EC2 instance and navigate to Add Storage tab. We can see Encryption as Not Encrypted as default value. It cannot be changed.


Instance got created and navigate to Volumes:

It shows –it is Not Encrypted.

Step 2: Create Snapshot:

We can see, it is not encrypted.

Now we will copy this snapshot and allow encrypt option for this.




Now we can see encrypted snapshot:


Step 4: Create Image.



Image is created under AMIs.


Now we can launch Instance and check whether it is accepting encrypted or not.


It is encrypted and will throw error message if we try to select not encryption.


Important facts about AWS EBS volume encryption:

  • root volume cannot be selected for encryption during instance launch.
  • non-root volume can be encrypted during launch or after launch.
  • root volume cannot be encrypted after the launch of an instance without creating a snapshot of it.

************************************************************************************************************************************************

Points to remember:

  • Volumes exist on EBS. Consider EBS as a virtual hard disk
  • Snapshots exist on S3. Consider snapshots as a photograph of the disk.
  • Snapshots are point in time copies of Volumes.
  • Snapshots are incremental — this means that only the blocks that have changed since your last snapshot are moved to S3.
  • To create a snapshot for Amazon EBS volumes that serve as root devices, you should stop the instance before taking the snapshot.
  • However you can take a snap while the instance is running.
  • You can create AMI’s from both Volumes and Snapshots.
  • You can change EBS volume sizes on the fly, including changing the size and storage type.
  • Volumes will ALWAYS be in the same availability zone as the EC2 instance.
  • To move an EC2 volume from one AZ to another, take a snapshot of it, create an AMI from the snapshot and then use the AMI to launch the EC2 instance in a new AZ.
  • To move an EC2 volume from one region to another, take a snapshot of it, create an AMI from the snapshot and then copy the AMI from one region to the other. Then use the copied AMI to launch the new EC2 instance in the new region.
  • Instance Store Volumes are sometimes called Ephemeral Storage.
  • Instance store volumes cannot be stopped. If the underlying host fails, you will lose your data.
  • EBS backed instances can be stopped. You will not lose the data on this instance if it is stopped.
  • You can reboot both, you will not lose your data.
  • By default, both ROOT volumes will be deleted on termination. However, with EBS volumes, you can tell AWS to keep the root device volume.
  • Snapshots of encrypted volumes are encrypted automatically.
  • Volumes restored from encrypted snapshots are encrypted automatically.
  • Snapshots can be shared, but only if they are unencrypted.

QUESTION and ANSWER:

  1. What are Benefits of Using EBS Volumes?

Ans : EBS volumes provide many benefits that are not supported by instance store volumes.

  1. Data availability: At the point when you make an EBS volume in an Availability Zone, it is consequently reproduced inside that zone to prevent data loss due to failure of any single hardware component.

We can attach an EBS volume to one instance only but single instance can have multiple volumes linked. Incase multiple volumes are attached to a single instance then we can stripe data across the volumes for increased I/O and throughput performance.

  • Data encryption: We can create encrypted EBS volumes with the Amazon EBS encryption feature. We can use encrypted EBS volumes to meet a wide range of data-at-rest encryption requirements.
  • Snapshots: Amazon EBS gives the ability to create snapshots of any EBS volume and write a copy of the data in the volume to Amazon S3, where it is stored in multiple Availability Zones.

Related Topics:

Chapter-2 EC2 Instance Termination

Chapter-3 EC2-Security Groups

Chapter-1 EC2 Instance Creation

Chapter-5 EC2-CloudWatch

Chapter 6 AWS CLI

Chapter 7 AWS Boot Strap Scripts

EC2 Knowledge Check

For latest updates please join FB group cloudvikas.com (search in FaceBook) os click on link Cloudvikasgroup