Making an Amazon EBS Volume Available for Use
After you attach an Amazon EBS volume to your instance, it is used as a block device. You can format the volume with any file system and then mount it. After you make the EBS volume available for use, you can access it in the same ways as you access any other volume.
To mount an EBS volume to your instance via CLI
- Connect to your instance using SSH.
- Use the lsblk command to view your available disk devices and their mount points to determine the correct device name to use
- This step assumes that you are mounting an empty volume. If you are mounting a volume that already has data on it, don’t use mkfs command it will format everything in the volume.
$ sudo mkfs -t ext4 /dev/xvdf
- Create a mount point directory for the volume using the following command.
$ sudo mkdir /mnt
- Mount the volume you created using the following command.
$ sudo mount /dev/xvdf /mnt
- With the following command make it mount automatically on system start.
$ sudo vim /etc/fstab
and add this:
/dev/xvdf /mnt1 auto defaults,nobootwait 0 0
Now, the volume has been mounted.