What is Mounting and Unmounting?
Think of your EC2 instance as a computer, and the EBS volume as an external hard drive (like a USB drive or external storage you plug into your computer).
Mounting: When you "mount" a volume, you're basically telling the computer (your EC2 instance) "Hey, connect this external hard drive so I can use it!" After you mount it, you can save files on it, read files from it, and treat it like any other part of your storage.
Unmounting: When you're done using the volume, you "unmount" it, which is like telling the computer "Okay, I'm done with this hard drive. Safely disconnect it!" You can still re-mount it later, but for now, you're just detaching it in a safe way.
Why Mounting/Unmounting is Needed?
Imagine plugging a USB drive into your laptop. To actually see the files on the USB drive, your laptop has to "recognize" it — this is like mounting.
When you're done using the USB drive, you "eject" it before pulling it out. That’s the same as unmounting — it ensures the computer has finished all tasks with the drive before disconnecting it safely.
How it Works in AWS (EC2 + EBS)
EBS (Elastic Block Storage) is like that external hard drive.
EC2 (Elastic Compute Cloud) is like your computer.
When you create a new EBS volume and attach it to an EC2 instance, you mount it so that your instance can use it (store files, run applications, etc.).
If you want to stop using that volume (maybe you want to attach it to another instance or save money), you would unmount it.
Basic Steps:
Mount the volume: Make it available for your EC2 instance (so you can save stuff on it).
Example: After you attach the volume, you create a folder in your EC2 instance, and then "mount" the EBS volume to that folder. Now, everything you put in that folder is saved on the EBS volume.
Use the volume: Save files, read files, or run applications on that EBS volume.
Unmount the volume: When you're done, you unmount it so it can be safely detached from the EC2 instance.
Example of Mounting/Unmounting
Mounting: After creating and attaching an EBS volume to an EC2 instance:
sudo mkdir /mnt/myebsvolume # Create a folder sudo mount /dev/xvdf /mnt/myebsvolume # Mount the EBS volume to that folder
Unmounting: When you no longer need to use the volume:
sudo umount /mnt/myebsvolume # Unmount it
In Summary:
Mounting: Connecting the EBS volume so you can use it in your EC2 instance (store and access data).
Unmounting: Safely disconnecting the EBS volume when you're done.
I hope that clears things up for you! It's just like connecting and safely removing an external hard drive from your computer. 😊
Subscribe to my newsletter
Read articles from Muhammad Sufiyan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Muhammad Sufiyan
Muhammad Sufiyan
As a former 3D Animator with more than 12 years of experience, I have always been fascinated by the intersection of technology and creativity. That's why I recently shifted my career towards MERN stack development and software engineering, where I have been serving since 2021. With my background in 3D animation, I bring a unique perspective to software development, combining creativity and technical expertise to build innovative and visually engaging applications. I have a passion for learning and staying up-to-date with the latest technologies and best practices, and I enjoy collaborating with cross-functional teams to solve complex problems and create seamless user experiences. In my current role as a MERN stack developer, I have been responsible for developing and implementing web applications using MongoDB, Express, React, and Node.js. I have also gained experience in Agile development methodologies, version control with Git, and cloud-based deployment using platforms like Heroku and AWS. I am committed to delivering high-quality work that meets the needs of both clients and end-users, and I am always seeking new challenges and opportunities to grow both personally and professionally.