No long stories straight steps.
Click on volumes under Elastic Block Store in EC2 dashboard
Create new EBS drive
Use already running instance or create new EC2 instance.
Again from EC2 dashboard navigate to volumes under Elastic Block Store. Select your volume that you want to attach and from action click attach and select your ec2 instance.
SSH into your EC2 instance
lsblk
this will list all devices attached to your instance.Try to identify new EBS volume name in the results
Check mountpoint column for that row and that should be empty and that's fine
sudo file -s /dev/xvdf
replace xvdf with your volume this command will result in/dev/xvdf: data
that means there is no file system associated with that drive. We have to format this newly created volume with some file system which is supported.sudo mkfs -t ext4 /dev/xvdf
this will format that newly created volume in ext4 file system.Now we will create mount point where we will mount this new volume in our system.
sudo mkdir /data
and thensudo mount /dev/xvdf/ /data
this will mount it to /data directory.Make sure we have mounted successfully by
lsblk
To mount this volume everytime we reboot run
sudo cp /etc/fstab /etc/fstab.orig
and thensudo nano /etc/fstab
. Enter following statement at the end and save this file/dev/xvdf /data ext4 defaults,nofail 0 2
Check if everything is on track by
sudo file -s /dev/xvdf
and now you should see everything about this new volume.Check if it is mounting on every reboot by
cd /
andsudo umount /data
will unmount and thensudo mount -a
will run the script to mount all volumes on reboot.Check back by
lsblk
and everything should be mounted as expected.
This post is written based on AWS documentation and please make sure you read all types of services and charges associated with them. You will be charged if you use any service out of their free tier. I am not responsible for your any types of issues and charges. Please use this post on your own understanding.
Top comments (0)