Working with EBS
EBS (Elastic Block Store) volumes are an important concept to understand when learning how to manage your EC2 instances. Amazon Elastic Block Store (Amazon 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. In this activity, we will walk through adding an EBS volume to an EC2 instance and then mount it, so the student will have a grasp of the process going forward.
Working with EBS Volumes
In this lab, we'll explore EBS volumes, including how to create them, attach them to instances, and mount them for use with our EC2 instances.
This written guide focuses on the steps necessary to complete the lab. It is recommended that you watch the accompanying video guide for extra details, clarifications, and insights.
Create a New Volume
First, we'll create a new volume. To begin, log in to AWS and navigate to the EC2 console.
- Click the Running Instances link at the top of the page, under Resources.
- From the menu on the left, select Volumes.
- Click the Create Volume button.
- Set the size to 10 GB and leave the rest of the settings as their default values.
- Click Create.
Attach the Volume
Next, we'll attach a new volume to our instance.
- From the list, look for the volume we just created. Right click it and select Attach Volume.
- Click in the instance field and select the existing instance. Leave the device as
- Click the Attach button.
Mount the Volume
Now that the volume has been attached, we'll need to create a filesystem and mount it to a data directory.
Copy the EC2 instance's public IP address, either from the AWS console or the Cloud Assessments console.
In a terminal window, connect to the instance via SSH:
Enter the password provided on the Cloud Assessments console.
Become the root user by entering
sudo suand entering your password again.
Check the attached devices using the
lsblkcommand. We should see a disk mounted at xvdf, corresponding to the
/dev/sdfdevice from the AWS console.
Create a new filesystem on the volume with the following command:
mkfs -t ext4 /dev/xvdf
Once the operation finishes, create a new mount point for the volume by running
Mount the volume to the newly created directory:
mount /dev/xvdf /data
Navigate to the new directory using
Create a new file by running
List the contents of the directory with
llto confirm that the file was created properly.
Finally, verify that the volume is mounted to the correct location, using
lsblkagain. The output should indicate that the disk is mounted to
In this lab, we learned how to set up an EBS volume for use with our EC2 instance. For more information, we recommend following along with the video associated with this lab.