How to attach and mount an EBS volume to EC2

Introduction

Why I need to attach and mount an EBS volume to EC2? Because sometimes I need to download large file. if only wait for download from blockchain is very slowly.

How to use

Attach

  1. Select the volume, right-click and select the attach volume option.
  2. Select the EC2 instance from the instance text box as shown below.
  3. Now, login to your EC2 instance and list the available disks using the following command.
1
lsblk
  1. Check if then volume has any data using the following command.
1
sudo file -s /dev/xvdf

Mount

  1. Create a directory of your choice to mount our new ext4 volume.
1
sudo mkdir -p /mnt/data
  1. Mount the volume to /mnt/data directory using the following command.
1
sudo mount /dev/xvdf /mnt/data
  1. cd into /mnt/data directory and check the disk space to validate the volume mount.
1
df -h .

Unmount

To unmount the volume, use the umount command as shown below.

1
umount /dev/xvdf

Conclusion

I think the solution is a wrong way but actually is very efficient.
So I have another solution on kubernetes. You can back up the large file like sqlite to s3 bucket and then using Init Container Pattern method to download file from s3. It’s a pretty solution. haha.