Provisioning and Mounting an Additional EBS Volume on an EC2 Ubuntu Instance


This project demonstrates how to create a new EBS volume, attach it to an EC2 Ubuntu instance, format the volume, and mount it for use. It covers essential AWS storage management skills.
Let’s start by launching a virtual machine using the AWS EC2 service. Go to the AWS Management Console, type EC2 in the search bar, and click on the EC2 service.
Go ahead and click on launch Instance button on the right hand side
Step-1: Provide a name for your EC2 instance
Step-2: Configure AMI template
An AMI (Amazon Machine Image) template defines the software configuration of your EC2 instance. It includes several parameters such as the user-preferred operating system (in this case, Ubuntu OS), additional software pre-installed before deployment, and other details like the AMI ID, publication date, boot mode, OS architecture, and description.
Step-3: Instance type
Choose the hardware configuration for your virtual machine—that is, the underlying physical server resources—based on your project requirements.
Step-4: Create or choose an existing key pair
Click on “create new key pair” link on the side.
Provide a name for your custom key pair. I recommend using the default cryptographic algorithm, RSA, and saving the private key file with a .pem
extension, as it is widely supported across AWS services. Once you’ve entered the name, click the Create key pair button.
Step-5: Network configuration
I will proceed with the default settings provided by AWS for now. Make sure to enable SSH traffic by checking the “Allow SSH traffic from” option. Since we'll be mounting the EBS volume to the system, we need SSH access to log into the instance. Set the source CIDR to 0.0.0.0/0
to allow access from the public internet (for demo purposes only). SSH is a secure protocol that enables encrypted remote access to your EC2 instance.
Step-6: Storage configuration
This is the default EBS root volume, where the operating system and system-level files are stored.
Note: It's considered best practice to create a separate EBS volume—for example, named personal-EBS-volume—to store user data, application files, or logs. This ensures better data management and avoids potential loss.
While EBS volumes are inherently persistent, the EBS root volume can behave ephemerally depending on how the EC2 instance is configured. By default, AWS may set the root volume to be deleted upon instance termination, which means all data on that volume is lost unless you modify this behavior. This makes it unsuitable for storing user data that needs to persist after the instance is stopped or terminated.
Once you’ve reviewed and are satisfied with the entire EC2 configuration in the Summary section, click the “Launch instance” button to deploy your virtual machine.
My Ubuntu-based EC2 instance has been successfully launched. Click on the Instance ID to view the instance details.
Now, let’s create a new EBS volume. On the left-hand side menu, under the Elastic Block Store section, click on Volumes.
On the top-right corner, click the “Create Volume” button.
Note: EC2 instances and EBS volumes are Availability Zone-specific. Make sure to identify the Availability Zone of your EC2 instance first, and then create the EBS volume in the same zone to ensure compatibility.
My EC2 instance is located in us-east-1b, and the default EBS root volume is also provisioned in the same Availability Zone.
Back to creation of new EBS volume
I’ll choose 2 GB as the volume size for demonstration purposes.
💡 Note: EBS volumes cannot be decreased in size once created—they can only be increased. Plan your storage needs accordingly.
In gp3 EBS volumes, the volume size is independent of IOPS and throughput (MiB/s) performance, allowing you to provision IOPS and throughput separately.
However, in gp2 volumes, the volume size directly affects the baseline IOPS and throughput — larger volumes deliver higher performance.
I have chosen "us-east-1b" to deploy this new EBS volume. Users can encrypt their EBS volumes, but we will not enable encryption in this demonstration.
Note: Users can add tags to their AWS resources for easier identification and management.
Once you finish configuring the EBS, click the "Create Volume" button.
I have successfully created a new EBS volume and deployed it in the same Availability Zone, "us-east-1b."
The volume is currently in "creating" mode. Once it becomes available, you can attach the new EBS volume to the EC2 instance.
My personal EBS volume is now in "available" mode.
Note: You do not need to stop a running EC2 instance to attach a new EBS volume. Volumes can be safely attached without downtime. However, if you need to modify or detach the root volume, it’s safer to stop the instance first.
To attach this new EBS volume to the EC2 instance, follow these steps:
Step-1: Select the EBS volume you would like to attach to the EC2 instance.
Step 2: In the top right-hand corner, click the Actions button. A dropdown menu will appear; select the "Attach Volume" option.
Step 3: A new window will appear. Select your running EC2 instance.
Step 4: Enter a device name (any device name).
Click on “attach volume” button
I have successfully attached the new EBS volume to my EC2 instance. To confirm this, return to the instances tab, switch to storage, and scroll down to block devices (refresh the page if necessary).
As you can see, my personal volume is now attached to my EC2 instance.
Now let's SSH into the EC2 instance.
In the top right-hand corner, click the connect button. A new page will appear; switch to the SSH client tab. Ensure you give executable permissions to your key pair file by using the AWS recommended command: sudo chmod 400 "18052025.pem"
. Copy the SSH command: ssh -i "18052025.pem" [ubuntu@ec2-54-174-113-254.compute-1.amazonaws.com](mailto:ubuntu@ec2-54-174-113-254.compute-1.amazonaws.com)
. I will embed this SSH command in a bash script and run it.
I logged into my virtual machine using VMware Workstation. In my Downloads folder, the key pair file "18052025.pem" is available, but it doesn't have executable permissions. Let's go ahead and update that.
Enter command, sudo chmod 400 “18052025.pem”
As you can see, read permissions have been granted to the user, while no permissions are given to groups or others. Create a new bash script and paste the SSH command into it.
Use the touch command to create a new file and end it with a .bash extension (to indicate a bash script).
touch <script-name>.bash
Open the script using any text editor you prefer. I will use the nano editor. Use the command nano <script-name>
To save the file, press Ctrl + S
.
To exit the file, press Ctrl + X
.
Note: Make sure the key pair file and the bash script are in the same directory.
Use the command bash <script-name>
I have successfully entered my EC2 instance using the SSH protocol.
Go ahead and update your EC2 instance using this command: sudo apt update -y
.
Note: It's always a good idea to update all existing system packages to their latest versions.
Now, become the superuser by using this command: sudo su
Step 1: Enter the command lsblk
to list all block devices in the system.
Step 2: Create a new mount directory using the mkdir command: mkdir /mnt/myebs
.
Step 3: Format the new volume with the EXT4 filesystem using the command: mkfs -t ext4 /dev/xvdi
mkfs
stands for make file system.The
-t
flag specifies the type of file system to create.ext4
is the file system type./dev/xvdi
is the name of the EBS volume.
Step 4: Now that the file system is specified, mount the EBS volume using the command: mount <device> <mount-point>
To check if your EBS volume has been successfully mounted to the directory, use the command lsblk
or df -h
.
df -h
is used to show the disk space usage of all mounted filesystems.
- The
-h
flag means "human-readable", which formats the output in GB, MB, etc., making it easier to understand.
As you can see, my personal EBS volume has been successfully mounted to the mount directory or mount point.
Now the user can change into the directory and add personal files, folders, scripts, logs, and more. Use the command cd <mount-point>
. In my case, the command is cd /mnt/myebs
.
Now I can create a new file called "sample.txt" using the touch command:
touch <file-name>
or
echo "string" > <file-name>
To view the contents of the file, use the cat
command:
cat <file-name>
Conclusion
This mini project showed how to create, attach, format, and mount a personal EBS volume to an EC2 Ubuntu server. I hope this helps fellow learners in their AWS journey.
For more hands-on projects and updates, feel free to connect with me on GitHub and LinkedIn.
Thank you for reading!
Subscribe to my newsletter
Read articles from Abhishek Balaji directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Abhishek Balaji
Abhishek Balaji
I'm a cloud and DevOps upskilling candidate focused on building practical skills through real-world AWS projects. I enjoy getting hands-on with core services like EC2, EBS, S3, and IAM, and documenting my learning journey through blog posts and GitHub repositories. Every project I complete is a step toward mastering cloud fundamentals and developing automation skills that align with DevOps practices. My goal is to grow into a confident, capable engineer who can design and manage scalable infrastructure. GitHub: https://github.com/abhishek-balaji-2025