In the previous post we had learned how to attach ebs volume to ec2 instance. Now in this post we will learn creating filesystem on ebs volume to store data.
For using ebs volume to actually store data, we need to create filesystem on the ebs volume. On a Linux server, the most recommended / used filesystems are ext4 and xfs. Though there might be number of use cases where companies might be using older filesystem like ext3.
It solely depends on the project / application and use case.
For creating filesystem on ebs volume to store data, I am using ext4 for this lab.
Like I have said it earlier. You MUST have basic Linux skills to move ahead in your career. You just cannot afford to ignore Linux and expect a job / career in IT. I have seen a lot of cases, where young graduate guys are straight away jumping on courses like AWS without any Linux skills. Just because their “some brother’s friend / known one” has told them to move to cloud and devops for career growth.
I will be talking on this learning curve in my next post. Not now.
Creating filesystem on ebs volume to store data.
Step #1 – After doing ssh to your ec2 instance. Get yourself “root” rights with “sudo su – “ and check with “fdisk -l” . The new block device / ebs volume must be shown in the output.
Step #2 – I will use old and trusted “fdisk” utility to create partition. For this demo, I am creating a 500MiB block device, which I will use to show the rest of the lab.
Now, this is the reason, I always say “Basic Linux administratoin skills (RHCSA Training) is needed to do anything in IT (cloud included).
Step #3 – Once done with creating a partition, use “partprobe” to update the kernel for the new partition. Confirm the newly created parition by using “lsblk” command. “lsblk” will show all the partitions, no matter, they are formatted or not.
Step #4 – Confirm that no filesytem is already present on the new parition (/dev/xvdf1), the name can be different in your case. As output of “blkid” is not showing our new partition (/dev/xvdf1), we can safely go ahead and format it.
Step #5 – I will be using “ext4” filesytem on the new partition.
Step #6 – Once done, we can confirm the presence of filesystem on the new parition, by using the “blkid” command again. This time the output must show the presence of “ext4” filesytem against the device “/dev/xvdf1”
Step #7 – Now we only need to create folder to be used as mount point and mount it, using “mount” command.
We can also give “df -h” command to see the currently mounted filesystems, and we should not see the new “/dev/xvdf1” in the output.
Now use the mount command to mount it and use it.
Finally, we can move inside /mydata directory and use it to store our important data.