How to attach EBS volume to EC2 instance
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.
This tutorial explains the detailed steps to attach EBS volume to EC2 instance.
Step1: Login to aws console
Step2: Create new volume as per the required size and type.
Step3: Select the created volume, right click and select the "attach volume" option.
Step4: Login to the ec2 instance and list the available disks.
#lsblk
For explaining the later steps, we are using the name '/dev/xvdb' for the new disks
Step5: Check if the volume has any data using the following command.
#file -s /dev/xvdb
If the above command output shows “/dev/xvdb: data”, it means your volume is empty.
Step6: Format the volume to ext4 filesystem.
#mkfs -t ext4 /dev/xvdb
Step7: Create the mount point folder
#mkdir /disk1
Step8: Mount the new volume
#mount /dev/xvdb /disk1
Step9: Modify the '/etc/fstab' file with the following line to set the mounting permanent
/dev/xvdb /disk1 ext4 defaults,nofail 0 0
Step10: Update the details
#mount -a
That's all....