1 - Mounting Elastic Block Storage onto a EC2 Instance
Hafeez Baig |
18 steps |
50 seconds
Refer to the following guide to learn how to use IAM in the cloud\
<https://scribehow.com/shared/Creating_an_IAM_User_and_User_Group_in_AWS_Management_Console__hWNiiXlcRJKFqYZZEJD-cg>
Refer to this guide to learn how to create an EC2 instance with Elastic Block Storage Volumes<https://scribehow.com/shared/Creating_EC2_Instances_with_Elastic_Block_Storage_Volumes__H_2IgXHhQk62AOL09PCbxw>
1
Sign in to **AWS Management Console** as an **IAM User**
**Pre-requisite** - Ensure you have selected the AWS region closest to your location\
For this guide, we will be using us-east-2 (Ohio) as a preferred choice
2
Type **EC2** in the search bar and click on **EC2** to view the EC2 Dashboard
**What is EC2 in AWS?**
Amazon Elastic Compute Cloud (Amazon EC2) is a web service provided by Amazon Web Services (AWS) that allows users to rent virtual servers, known as instances, on which they can run their own applications. EC2 provides resizable compute capacity in the cloud, making it easy to scale computing resources up or down based on demand.
3
On the EC2 dashboard click on **Instances** from the left bar to view the EC2 instances
4
**Instances** wizard will open, select the instance **EBS Instance B**
5
Click on the **Actions** dropdown on the top right corner and select the **Connect** button
6
**Connect to Instance** wizard will open, scroll the page and click on the **Connect** button
7
Once you have successfully connected to the EC2 instance, enter the command **[[lsblk]]** to list all the storage devices
**What is the "lsblk" command?**
The **lsblk** command in Linux lists information about block devices, such as disks and partitions, including their names, sizes, types, and mount points. It helps users understand the storage layout of their system.
8
Move to the root directory by typing this command [[cd /]] then type[[ ls ]]command to list all the directories
**What is the "ls" command?**
The **ls** command in Unix-like systems lists directory contents. It shows files and directories in the current directory by default, with options available for customizing the output format and content.
9
Type the command [[sudo file -s /dev/sdb ]], /dev/sdb is linked to xvdb in the file system
**What does sudo file -s /dev/sdb do?**
`sudo file -s /dev/sdb` safely (with `sudo`) identifies the file system type (using `file -s`) of a block device (like a hard drive) at `/dev/sdb`.
10
Type command [[sudo mkfs -t xfs /dev/xvdb ]]to create a filesystem in /dev/xvdb
**What**`sudo mkfs -t xfs /dev/xvdb`**does?**
The command `sudo mkfs -t xfs /dev/xvdb` creates a new XFS filesystem on the block device `/dev/xvdb` with elevated privileges.
11
To mount the volume in a directory, create a directory using the command [[sudo mkdir data]]
**What is mkdir command?**
The `mkdir` command in Unix-like systems is used to create directories (folders). It creates a new directory with the specified name in the current directory by default, or at a specified location if provided.
12
Mount a volume on a directory by using the command [[sudo mount /dev/xvdb /data]]
**What is**`sudo mount /dev/xvdb /data`**command?**
The command `sudo mount /dev/xvdb /data` mounts the filesystem located on the block device `/dev/xvdb` onto the directory `/data`, granting superuser privileges with `sudo`.