Now, log into the EC2 instance websrv01 and switch to root user and run the below command.
Now we can see that we have one more disk /dev/xvdf with 5GB of storage.
You may be wondering why the new disk name is not /dev/xvdb instead it is /dev/xvdf because there is a separate algorithm which assigns the name of the disk. So, it may be in sequence or may not be.
DISK PARTITIONING UTILITY (fdisk)
fdisk is a command-line utility that provides disk partitioning functions in Linux. So we are going to use this with the disk we just got after attaching the volume.
For this, run the below command to create a new partition with the available disk partition.
# fdisk /dev/xvdf
Use m to list out various options that can be used in fdisk.
Use p to list out the partition information first and
Use n to create a new partition.
Follow the steps as shown in the below screenshot.
And this will give you a list of options.
CREATING PARTITION IN HARDDISK
As we need to create the partition, so we will run the n command . Each disk has 4 primary partition and then has extended partitions.
The hard disk is divided into sectors.
NOTE
Now sectors are used basically to allocate the size in the partition Here we can see that by default sector starts from 2048 and if we are going to select the last sector, this partition will be of the complete hard disk.
As we understand size better in terms of GB and MB, so we can also write +3G, if we want to create a partition of 3GB out of 5GB of the hard disk.
We can see from the above screenshot that our first partition of size 3GB is ready.
PRINTING PARTITION
We can print the partition with the p command.
So, we can see that for hard disk /dev/xvdf, we have our first partition created as /dev/xvdf1.
As we can see the newly created partition. So now we are going to write it with the w command and will exit from the fdisk utility.
Summary
In this article, we learned a lot of interesting things like how one can mount a directory to a partition, we learned about volumes, mounting, and printing partition. In the next article, we will be taking this further to do some more practical stuff.
I hope you find this article helpful. Stay tuned for more … Cheers!!