DEV Community

Cover image for Mount EBS Volume with EC2 Linux Instance
Nahid Chowdhury
Nahid Chowdhury

Posted on

1 1

Mount EBS Volume with EC2 Linux Instance

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
Enter fullscreen mode Exit fullscreen mode

Image

After that create a mount point in the /mnt folder.

> sudo mkdir -p /mnt/db
Enter fullscreen mode Exit fullscreen mode

/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
Enter fullscreen mode Exit fullscreen mode

Image

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
Enter fullscreen mode Exit fullscreen mode

Congratulations you have successfully mounted the volume and it's ready to use. For checking it you can use lsblk command.

Image

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
Enter fullscreen mode Exit fullscreen mode

Save & Close the file. Enjoy!

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay