Formatting and mounting

The EBS volume is attached to the EC2 instance. However, you need to make the volume available to use by formatting and mounting it. There are three steps here:

  1. Format the volume with mkfs
  2. Create a mount point
  3. Mount the volume
graph LR; A[Format the volume] -->|Verify with lsblk -fs| B[Create the mount point] B -->|Verify with ls -lah /| C[Mount the volume] C -->|Verify with mount| E[Done]

First, connect to the EC2 instance that you created earlier as you did in the Logging in section.

Check the available disk devices with the lsblk command to ensure that you have attached the volume to your instance.

It will return something similar to:

NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 disk 
└─xvda1 202:1    0   8G  0 part /
xvdf    202:80   0  10G  0 disk 

The root device is /dev/xvda. The EBS volume that we just created and attached /dev/xvdf.

The attached volume is empty and you must create a file system on it before you can mount and use it. Issue the following command:

sudo mkfs -t xfs /dev/xvdf
Verification steps

The next step is to create a mount point directory for the volume. This mount point is where we will read and write files to the volume:

sudo mkdir /data
Verification steps

Finally, we mount the volume at the directory:

sudo mount /dev/xvdf /data
Verification steps

At this point, we have created a new EBS volume, formatted it, and mounted it in the Linux instance. There is one more step to complete to configure the system to mount the new volume at boot time. Proceed to the next section to configure the filesystem table.