How to Create an Amazon EBS Volume

EBS vs Instance Store,

How to Create an Amazon EBS Volume – Step-by-Step Guide with Examples

Amazon Elastic Block Store (EBS) is a scalable block storage service used with Amazon EC2 instances. It allows you to store persistent data, create snapshots, and optimize performance based on workload requirements.


1. Prerequisites for Creating an EBS Volume

Before creating an EBS volume, ensure:
✅ You have an AWS account and access to the AWS Management Console or AWS CLI.
✅ You know the AWS region where your EC2 instance is running (EBS volumes are region-specific).
✅ You have identified the required volume type (gp3, gp2, io2, st1, sc1) based on your workload.


2. Methods to Create an EBS Volume

There are three ways to create an EBS volume:
1️⃣ Using AWS Management Console (GUI)
2️⃣ Using AWS CLI (Command Line Interface)
3️⃣ Using AWS SDKs (For automation in Python, Java, etc.)


3. Method 1: Creating an EBS Volume via AWS Console (GUI)

Step 1: Open the EC2 Dashboard

1️⃣ Sign in to AWS Management Console
2️⃣ Navigate to EC2 Dashboard
3️⃣ Click on Volumes under the Elastic Block Store section.

Step 2: Create a New EBS Volume

1️⃣ Click on Create Volume
2️⃣ Configure the volume:

  • Volume Type: Select gp3 (General Purpose SSD) for most workloads.
  • Size: Enter storage size in GiB (e.g., 100 GiB).
  • Availability Zone: Choose the same AZ as your EC2 instance.
  • IOPS (for SSDs): Set desired IOPS (e.g., 3000 for gp3).
  • Throughput (for gp3): Set throughput in MB/s if needed.
  • Encryption: Enable encryption if required.

3️⃣ Click Create Volume – The volume is now created!


4. Method 2: Creating an EBS Volume via AWS CLI

Step 1: Install and Configure AWS CLI

If not already installed, install AWS CLI and configure it with:

aws configure

Enter AWS Access Key, Secret Key, Region, and Output Format (JSON/CLI table).

Step 2: Run CLI Command to Create Volume

Use the following command to create a 100 GiB gp3 volume in us-east-1a:

aws ec2 create-volume \
    --size 100 \
    --region us-east-1 \
    --availability-zone us-east-1a \
    --volume-type gp3 \
    --encrypted

Output Example:

{
    "VolumeId": "vol-0abc123xyz",
    "Size": 100,
    "AvailabilityZone": "us-east-1a",
    "State": "creating",
    "VolumeType": "gp3",
    "Encrypted": true
}

📌 Note: Replace us-east-1a with the Availability Zone of your EC2 instance.


5. Method 3: Creating an EBS Volume using AWS SDK (Python – Boto3)

For automation, you can create an EBS volume using Boto3 (AWS SDK for Python).

Step 1: Install Boto3

pip install boto3

Step 2: Create an EBS Volume using Python

import boto3

ec2 = boto3.client('ec2', region_name='us-east-1')

response = ec2.create_volume(
    Size=100,
    AvailabilityZone='us-east-1a',
    VolumeType='gp3',
    Encrypted=True
)

print(f"EBS Volume Created: {response['VolumeId']}")

📌 Note: Ensure you have the correct IAM permissions to create EBS volumes.


6. Attaching EBS Volume to an EC2 Instance

Once the EBS volume is created, you must attach it to an EC2 instance.

Step 1: Attach the EBS Volume via Console

1️⃣ Go to EC2 Dashboard > Volumes
2️⃣ Select the newly created volume
3️⃣ Click on Actions > Attach Volume
4️⃣ Choose the EC2 instance and specify the device name (e.g., /dev/xvdf)
5️⃣ Click Attach

Step 2: Attach the EBS Volume via CLI

aws ec2 attach-volume \
    --volume-id vol-0abc123xyz \
    --instance-id i-0123456789abcdef \
    --device /dev/xvdf

7. Formatting & Mounting the EBS Volume (Linux)

After attaching, format and mount the volume in your EC2 instance.

Step 1: SSH into the EC2 Instance

ssh -i your-key.pem ec2-user@your-instance-ip

Step 2: List Available Disks

lsblk

📌 The new volume will appear as /dev/xvdf (or another device name).

Step 3: Format the Volume

sudo mkfs -t ext4 /dev/xvdf

Step 4: Mount the Volume

sudo mkdir /data
sudo mount /dev/xvdf /data

Step 5: Verify the Mount

df -h

📌 To make the mount persistent after reboot, add the following line to /etc/fstab:

/dev/xvdf  /data  ext4  defaults,nofail  0  2

8. Creating an EBS Snapshot (Backup)

To back up your data, create an EBS snapshot.

Step 1: Create a Snapshot via AWS Console

1️⃣ Go to EC2 Dashboard > Volumes
2️⃣ Select your EBS Volume
3️⃣ Click Actions > Create Snapshot
4️⃣ Provide a name and description, then click Create Snapshot

Step 2: Create a Snapshot via CLI

aws ec2 create-snapshot \
    --volume-id vol-0abc123xyz \
    --description "Backup snapshot of my volume"

9. Deleting an EBS Volume

Before deleting, ensure:
✔️ The volume is detached from EC2.
✔️ You have a backup (snapshot) if data is important.

Step 1: Delete via Console

1️⃣ Go to EC2 Dashboard > Volumes
2️⃣ Select the volume and click Actions > Delete Volume

Step 2: Delete via CLI

aws ec2 delete-volume --volume-id vol-0abc123xyz

10. Conclusion

Amazon EBS provides persistent, scalable storage for EC2 instances.
✅ You can create EBS volumes via AWS Console, CLI, or SDKs (Python, Java, etc.).
✅ After creation, attach, format, and mount the volume for use.
Snapshots enable backups and can be used to restore data.

If you need more information or want to outsource your AWS project, feel free to contact us! We provide expert AWS solutions, including EBS management, EC2 setup, cost optimization, and infrastructure maintenance.

📩 Get in touch today! 🚀

About Anant 413 Articles
Senior technical writer