Working with EBS

Amazon Elastic Block Storage (Amazon EBS)

As the name defines, Amazon Elastic Block Storage is just a storage block used in amazon services. It can be attached with an EC2 for storage only or it can be used for the boot partition as well. EBS is highly available,  highly reliable and can be operated independently from EC2.

 

 

Here in this task we are going to create an EBS volume and attach it to a new EC2 instance.

Step 1: For this, we have to create an EC2 instance first.

You can follow the below link to create the EC2 instance

https://technetworkz.wordpress.com/2018/03/28/amazon-ec2/ ‎

  • Go to EC2 from the Services menu at the top
  • To view the current instances, click on Instances

Step 2: Now we are going to create a new Volume to attach to this EC2

  • In the navigation panel on the left side, click on Volumes and Go to Create Volume

Configure the below settings on the page

  • Volume Type: General Purpose SSD (GP2)
  • Size (GiB): 1
  • Availability Zone: Same availability zone as EC2 instance
  • Tags: Create Additional Tags with Key: Name and Value: My Volume

Step 3: After these configurations are set, finish the creation by clicking on Create Volume and now the new volume will appear in the list and the state will be changed to available.

Step 4: Now we need to attach our new volume to the Amazon EC2 instance.

  • Select My Volume and go to Actions menu and click on Attach Volume
  • From the displayed instances, select the instance appeared.
  • Now click on the Attach option  

This will attach your Volume to the EC2 instance.

Step 5: Download the key pair to connect to your EC2 instance using PUTTY

 To connect to an instance Download the PPK file. and we require Putty installed on the local system.

  • Open putty and for Hostname enter the public IP address of the instance.

Here we are not using password instead, we are using a key file to login which we have downloaded previously.

  • To connect with a key file, go to connection list, Expand SSH and click Auth.
  • Browse the PPK file and click Open.
  • Username will be asked and enter ec2-user

Now you will be inside the Linux platform web instance.

 

After successfully logging in, we are going to create and configure the file system. We need to manually add the new volume to the Linux instance. The file system should be on ext3 format and mount point will be /mnt/data-store

Step 6: To view the current storage, type the below command and press enter.

df -h

Step 7: To create an ext3 file system on the new volume

sudo mkfs -t ext3 /dev/sdf

Step 8: Create a directory for mounting the new storage volume

sudo mkdir /mnt/data-store

Step 9: Mount the new volume to the location we created on the previous step

sudo mount /dev/sdf /mnt/data-store

Step 10: To mount this volume whenever the instance is started, we need to reconfigure the linux instance by adding a line in /etc/fstab

Running the below command will enable it for you.

echo “/dev/sdf /mnt/data-store ext3 defaults,noatime 1 2” | sudo tee -a /etc/fstab

 To view the configuration file and verify

cat /etc/fstab

and view the available storage again using df -h command, here we can see that an additional line has been added showing the new volume.

 

We have now completed the steps for the creation of EBS and attached it with an EC2 instance. 🙂

 

 

 

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.