Create a PVC then 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
Select the volume, right-click and select the attach volume option.
Select the EC2 instance from the instance text box as shown below.
Now, login to your EC2 instance and list the available disks using the following command.
1
lsblk
Check if then volume has any data using the following command.
1
sudo file -s /dev/xvdf
Mount
Create a directory of your choice to mount our new ext4 volume.
1
sudo mkdir -p /mnt/data
Mount the volume to /mnt/data directory using the following command.
1
sudo mount /dev/xvdf /mnt/data
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.