How to Mount the EBS volume to EC2 Ubuntu Instance via CLI

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
$ lsblk
ebs
  • 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.

One thought on “How to Mount the EBS volume to EC2 Ubuntu Instance via CLI

Leave a Reply

Your email address will not be published. Required fields are marked *

thirteen − ten =