Sponsors

Create And Mount Amazon AWS EC2 EBS Storage To AWS EC2 Linux Instance

Amazon’s AWS products are pretty amazing and allow you to scale with ease for short or long term projects. One thing that can be helpful is mounting extra storage to AWS instances so you have the ability to unmount the storage and mount to different instances in the future. The other benefit is the ability to terminate an Amazon AWS instance and keep the Elastic Block Store (EBS) volume to use on another AWS instance at a later date. Use the directions below to create an Amazon EC2 EBS volume, attach the volume to an Amazon AWS instance, format the volume, and then mount the volume to the instance.

Create Amazon AWS EC2 Elastic Block Store Volume:

Amazon’s Elastic Block Store volumes or EBS volumes can be thought of as hard drive space that you are reserving such as an external hard drive located on AWS for you to mount or unmount at any time you like to any instance within the same location. Make sure location is considered before creating the EBS volume and adding data to the volume. EBS volumes must be in the same exact location as the instance so the AWS region is not enough. Take for instance an EBS volume located in US East Virginia us-east-1A cannot be mounted to an AWS instance located in US East Virginia us-east-1B. You would need to create the EBS instance in the us-east-1c location to be able to mount the storage or EBS volume to a AWS EC2 GPU instance that is also running in us-east-1c. If you want storage that can be mounted across locations then you should consider AWS S3 storage however the speeds will be much different than mounting an AWS EBS volume from the same location.

Login To AWS: First login to your AWS management console located at https://aws.amazon.com.

AWS EC2 Console Dashboard: Click on Ec2 in the list of AWS products or if you are already logged in click Ec2 in the top navigation bar which will take you to the EC2 Console Dashboard as shown in the below example image.Make sure that you select the correct region once the EC2 Console Dashboard is displayed similar to the above example image. Again the AWS EC2 EBS volume must be in the exact location as the AWS Ec2 instance you want to mount to.

Elastic Block Store Volumes: Now click Volumes located in the left navigation underneath Elastic Block Store to open the list of EBS volumes associated to your account in this specific region as shown in the below example image.Notice in the above example I have a single 100GB EBS volume where I am storing some wordlists and oclHashcat items that I use for password cracking.

Create EBS Volume: Click the Create Volume button located in the top left corner of the center column of the Elastic Block Store Console Dashboard window which will launch the below EBS volume creation wizard.Simply fill in the details for your new Elastic Block Store volume as shown in the below example image. Again I want to note that the volume must be created in the exact location of the AWS EC2 instance you want to mount to. So keep in mnind that if the EBS volume is created in us-east-1a it will not be able to be mounted to a EC2 instance located in us-east-1b.Once the details have been entered click the Yes, Create button to create the EBS volume. Once the Yes, Create button is clicked the Create EBS Volume wizard will close and the new EBS volume will display in the list of Elastic Block Store volumes located in this AWS location as shown in the below example image.

You now have created an Amazon Elastic Block Store volume that can be formatted and mounted to an Amazon AWS EC2 instance. Below are the instructions for formatting and mounting the volume to an AWS EC2 instance.

Format & Mount Elastic Block Store Volume To AWS EC2 Instance:

Keep in mind that during this example we are mounting EBS volumes to Linux AWS instances.

Attach EBS Volume To Instance: Once you have an existing volume the first thing you need to do is attach the EBS volume to the instance where you want to mount it. This can be accomplished by right clicking on the EBS volume and clicking AttachVolume from the menu that appears as shown in the below example image.Once you select Attach Volume the below window will appear over top of the list of EBS volumes.Select the Instance you want to attach the EC2 Elastic Block Store volume to as shown in the below example image.Click the Yes, Attach button to attach the EBS volume to the instance you selected. Once the volume is attached the list of volumes will now display the volume attached to the instance as shown in the below example image.

Login To AWS Instance:Next login to the AWS instance where you attached the EBS volume. You can see that the new EBS volume is attached to the instance by using fdisk as shown in the below example output. In this case the new volume is attached as /dev/xvdf shown below with roughly 10GB of space.Use fdisk To Display Attached Volumes:

Format New EBS Volume:You only need to format the volume the first time you use it so this step can be skipped next time you want to mount the volume to another instance. Use mkfs to format the EBS volume as ext3 shown in the example syntax below.Format EBS Volume As ext3 Using mkfs On Linux AWS Instance:

Make Directory & Mount EBS Volume:First create a directory to mount the EBS volume to such as “/mnt/ebs-volume” and then mount the volume use the mount command within Linux. Below there is example output showing a directory being created and the EBS volume being mounted to the new directory.Create New Directory & Mount AWS EBS Volume To Linux AWS Instance: