DEV Community

Cover image for Mounting an EBS Volume on EC2
Ritesh Singh
Ritesh Singh

Posted on

Mounting an EBS Volume on EC2

How to Attach and Mount Extra EBS Volume to Linux EC2 in AWS | Mounting EBS Volume

🎯 Objective

Learn how to attach, mount, and use an EBS volume with an EC2 instance for persistent storage in AWS.


πŸ› οΈ AWS Services Used

  • EC2 (Elastic Compute Cloud): Instance to attach volume

  • EBS (Elastic Block Store): Persistent block storage

  • IAM: Proper permissions for EC2 access


πŸ“‹ Steps

1. Create an EBS Volume

  1. Go to AWS Console β†’ EC2 β†’ Elastic Block Store β†’ Volumes β†’ Create Volume

  2. Choose Volume type (e.g., General Purpose SSD gp3)

  3. Set Size (e.g., 1 GB for testing)

  4. Select the same Availability Zone as your EC2 instance

  5. Click Create Volume

2. Attach Volume to EC2

firstly launce an ec2 instance in same availability zone

  1. Select the volume β†’ Actions β†’ Attach Volume

  2. Choose the EC2 instance

  3. Click Attach


3. Connect to EC2 & Mount Volume

  1. SSH into your EC2 instance:
ssh -i mykey.pem ec2-user@<EC2-Public-IP>
Enter fullscreen mode Exit fullscreen mode

after ssh switch to root user using sudo su -

2 . After ssh switch into root user

sudo su -
Enter fullscreen mode Exit fullscreen mode

3 . use command

df -h 
Enter fullscreen mode Exit fullscreen mode

4 . Format the Volume (if needed)

Check if filesystem exists:

sudo file -s /dev/nvme1n1
Enter fullscreen mode Exit fullscreen mode

If output shows data, format it:

sudo mkfs -t ext4 /dev/nvme1n1
Enter fullscreen mode Exit fullscreen mode

Note β€”> replace with your disk name like /dev/xvdf in my case it is not xvdf it is nvme1n1

4. Mount the Volume

  • Create a mount point:
sudo mkdir /mnt/myvolume
Enter fullscreen mode Exit fullscreen mode
  • Mount it:
sudo mount /dev/nvme1n1 /mnt/myvolume
Enter fullscreen mode Exit fullscreen mode
  • Verify:
    df -h
Enter fullscreen mode Exit fullscreen mode

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1759419506610/7160c0f9-5438-429f-8f06-4e43d488d0ae.png )
Enter fullscreen mode Exit fullscreen mode

## 🌐 Connect With Me

Top comments (0)