What is Amazon EBS?
Amazon EBS is a block storage service that provides scalable and persistent storage volumes. They behave like raw, unformatted block devices. You can mount these volumes as devices on your EC2 instances. EBS volumes are essentially like virtual hard drives that can be used to store data, databases, and application files and they persist independently from the life of the instance. A file system can be created on top of these volumes, or used in any way you would use a block device (such as a hard drive). You can dynamically change the configuration of a volume attached to an instance.
It is recommended to use Amazon EBS for data that must be quickly accessible and requires long-term persistence.
Amazon EBS Volumes Types
EBS volumes are available in different types optimized for different workloads, including:
General Purpose SSD (
gp2
andgp3
) - balance price and performance for a wide variety of transactional workloads. These include virtual desktops, medium-sized single-instance databases, latency-sensitive interactive applications, development and test environments, and boot volumes. Recommended for most workloads.Provisioned IOPS SSD (
io1
orio2
) - the highest-performance Amazon EBS storage volumes designed for critical, IOPS-intensive, and throughput-intensive workloads that require low latency.Cold HDD (
sc1
) - The lowest-cost HDD design for less frequently accessed workloads.Throughput Optimized HDD (
st1
) - provide low-cost magnetic storage that defines performance in terms of throughput rather than IOPS. Designed to support frequently accessed data.
They differ in performance characteristics and price, allowing you to tailor your storage performance and cost to the needs of your applications
Hands-on Lab Overview
There are 3 ways of creating an EBS Volume:
Create and attach EBS volumes when you launch instances;
Create an EBS volume from a previously created snapshot and attach it to a running instance.
Create an empty EBS volume and attach it to a running instance.
In this hands-on, we will create an empty EBS and attach it to the running EC2 instance using AWS Management Console and AWS CLI.
Hands-on Lab
Creating an empty EBS via AWS Console
To create an empty EBS volume using the console
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Volumes.
Choose Create volume.
For Volume type, choose the type of volume to create.
For Size, enter the size of the volume, in GiB.
(
io1
,io2
, andgp3
only) For IOPS, enter the maximum number of input/output operations per second (IOPS) that the volume should provide.(
gp3
only) For Throughput, enter the throughput that the volume should provide, in MiB/s.For Availability Zone, choose the Availability Zone in which to create the volume. A volume can be attached only to an instance that is in the same Availability Zone.
For Snapshot ID, keep the default value (Don't create volume from a snapshot).
Set the encryption status for the volume.
If your account is enabled for encryption by default, then encryption is automatically enabled and you can't disable it. You can choose the KMS key to use to encrypt the volume.
If your account is not enabled for encryption by default, encryption is optional. To encrypt the volume, for Encryption, choose Encrypt this volume and then select the KMS key to use to encrypt the volume.
Note: Encrypted volumes can be attached only to instances that support Amazon EBS encryption.
(Optional) To assign custom tags to the volume, in the Tags section, choose Add tag, and then enter a tag key and value pair.
Choose Create volume.
Note: The volume is ready for use when the Volume state is available.
To use the volume, attach it to an instance.
Creating an empty EBS via AWS CLI
To create an empty Amazon Elastic Block Store (EBS) volume using the AWS Command Line Interface (CLI), use the create-volume
command.
aws ec2 create-volume --availability-zone us-east-1a --size 10 --volume-type gp2
Replace the placeholders with the appropriate values:
<availability-zone>
: The AWS availability zone where you want to create the volume. For example, "us-east-1a".<size-in-gigabytes>
: The size of the volume you want to create, in gigabytes.<volume-type>
(optional): The EBS volume type you want to create (e.g., "gp2" for General Purpose SSD, "io1" for Provisioned IOPS SSD, etc.). If not specified, it will default to "gp2".