Amazon Elastic Block Store (EBS) is an easy-to-use, scalable, high-performance block-storage service designed to work with EC2 instances. Unlike the instance store volume that comes with an EC2 instance, which is ephemeral and gets deleted when the instance is terminated, EBS volumes are independent of the instance and persist even after the instance is terminated. This means that any data written to the EBS volume will be preserved and can be accessed when the instance is restarted or launched again. There are several reasons why you might want to attach a separate EBS volume to an EC2 instance. Some of them are,
1. Data Persistence
2. Scalability and flexibility
3. Performance
In this blog post, we will learn about mounting an EBS instance in a Ubuntu Linux machine.
After attaching an EBS volume with a running EC2 instance, you can check it using the list block command
> lsblk
After that create a mount point in the /mnt
folder.
> sudo mkdir -p /mnt/db
/mnt/db
folder will be used for mounting the volume. So let's create the ext4
file system in the newly attached volume xvdf
> sudo mkfs -t ext4 /dev/xvdf
Now our file system is ready in the volume /dev/xvdf
. For mounting it with /mnt/db
we just need to use the mount command.
> sudo mount /dev/xvdf /mnt/db
Congratulations you have successfully mounted the volume and it's ready to use. For checking it you can use lsblk
command.
For initializing the attached volume after an instance reboot/restart we can use the Linux file systems table /etc/fstab
. Open the file /etc/fstab
using nano
and add the below-mentioned line at the end of the file.
/dev/xvdf /mnt/db ext4 defaults,nofail 0 2
Save & Close the file. Enjoy!
Top comments (0)