Practical Guide to EBS, Mounting, and Storage Management — Decoding DevOps [09]

Bhavyansh @ DiversePixel
3 min readJun 28, 2024

--

Introduction

Elastic Block Store (EBS) is a high-performance, easy-to-use block storage service designed for use with Amazon EC2 for both throughput and transaction-intensive workloads. Understanding how to manage EBS volumes, including mounting and unmounting, is crucial for anyone working with AWS. This guide will walk you through the basics of EBS, types of EBS volumes, and the practical steps for managing these volumes.

Photo by Alina Grubnyak on Unsplash

Elastic Block Store (EBS)

EBS provides persistent block storage volumes for use with Amazon EC2 instances. Each EBS volume is automatically replicated within its Availability Zone to protect you from component failure, offering high availability and durability.

Key Features

  • Virtual hard disk: Works similarly to traditional hard disks.
  • Snapshots: Backup of EBS volumes for data protection and disaster recovery.

Types of EBS Volumes

  1. General Purpose SSD (gp2 and gp3): Suitable for a wide variety of workloads, including system boot volumes, virtual desktops, low-latency interactive applications, and development and test environments.
  2. Provisioned IOPS SSD (io1 and io2): Designed for critical business applications that require sustained IOPS performance, such as large databases.
  3. Throughput Optimized HDD (st1): Ideal for frequently accessed, throughput-intensive workloads like big data and data warehouses.
  4. Cold HDD (sc1): Best for less frequently accessed data, such as file servers.
  5. Magnetic (standard): Older generation, useful for infrequently accessed data where performance isn’t critical.

Creating and Managing EBS Volumes

Step 1: Creating an EBS Volume

  1. Open the EC2 Dashboard.
  2. Navigate to Volumes under the Elastic Block Store section.
  3. Click Create Volume.
  4. Select the volume type, size, and Availability Zone.
  5. Click Create Volume.

Step 2: Attaching an EBS Volume to an EC2 Instance

  1. In the Volumes section, select the volume you created.
  2. Click Actions and select Attach Volume.
  3. Choose the instance to attach the volume to and specify the device name (e.g., /dev/xvdf).
  4. Click Attach.

Mounting and Unmounting EBS Volumes

Mounting an EBS Volume

  1. Connect to your EC2 instance via SSH.
  2. Create a directory to mount the volume:
sudo mkdir /mnt/data

3. Identify the new device using lsblk or df -h:

lsblk

4. Create a file system on the volume (if not already formatted):

sudo mkfs -t ext4 /dev/xvdf

5. Mount the volume to the directory:

sudo mount /dev/xvdf /mnt/data

6. Verify the mount:

df -h

Making the Mount Permanent

  1. Edit the /etc/fstab file:
sudo vi /etc/fstab

2. Add the following line to mount the volume at boot:

/dev/xvdf  /mnt/data  ext4  defaults,nofail  0  2

Unmounting an EBS Volume

  1. Unmount the volume:
sudo umount /mnt/data
  1. Detach the volume from the EC2 instance:
  • Go to the Volumes section in the EC2 Dashboard.
  • Select the volume and click Actions > Detach Volume.

Troubleshooting and Best Practices

  • Ensure the volume is in the same Availability Zone as your EC2 instance.
  • Always take snapshots of your volumes regularly for backups.
  • Monitor the performance and adjust the volume type based on your workload needs.

Conclusion

Managing EBS volumes, including creating, attaching, mounting, and unmounting, is an essential skill for AWS users. This guide has covered the fundamental aspects of EBS, providing a step-by-step approach to handle these tasks efficiently. By following these practices, you can ensure your storage management is robust and reliable, supporting your applications’ needs.

--

--

Bhavyansh @ DiversePixel

Hey I write about Tech. Join me as I share my tech learnings and insights. 🚀