πŸ’½ AWS 112: Plug and Play - How to Attach an EBS Volume to an EC2 Instance

πŸ’½ AWS 112: Plug and Play - How to Attach an EBS Volume to an EC2 Instance

Source: Dev.to

🧱 Expanding Your Horizons: Attaching Extra Storage to Your Cloud Server ## 1. Introduction: Why Attach a Secondary Volume? πŸ’‘ ## 2. Step-by-Step Guide: Attaching nautilus-volume to nautilus-ec2 ## Step 2.1: Locate your EBS Volume ## Step 2.2: Attach to the Instance ## Step 2.3: Verify the Attachment ## 3. Key Takeaways πŸ“ ## 4. Common Mistakes to Avoid 🚫 ## 5. Conclusion + Call to Action! 🌟 Hey Cloud Builders! πŸ‘‹ Welcome to Day 12 of the #100DaysOfCloud Challenge: Attach EBS Volume! We are continuing our systematic infrastructure migration with KodeKloud Engineer. Today, we are bridging the gap between compute and storage. Our mission: Attach the existing EBS volume named nautilus-volume to the EC2 instance named nautilus-ec2 in the us-east-1 region using the device name /dev/sdb. Most EC2 instances come with a "Root Volume" where the Operating System lives. However, in professional DevOps, we often attach secondary volumes for specific data. Let's get this "virtual hard drive" plugged in! πŸ”Œ We will use the EC2 Dashboard to perform this operation. Pro-Tip: Ensure the volume state is "available" (meaning it's not currently attached to anything else). Success! Your server has now been upgraded with extra storage space. πŸŽ‰ You've successfully managed the storage lifecycle of your cloud resources! Learning to handle EBS volumes is a core skill for anyone managing databases or stateful applications in AWS. How are you finding the 100 Days of Cloud Challenge so far? πŸ›‘οΈ Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse - Data Separation: Keeping your application data or databases on a separate volume makes it easier to manage backups (snapshots) and move data between instances. - Performance: You can choose different volume types (like io2 for high-speed databases) for your data volume while keeping a standard gp3 for your OS. - Persistence: If the OS crashes and you need to delete the instance, the secondary data volume can be easily detached and saved! - Log in to the AWS Console and navigate to the EC2 Dashboard. - In the left sidebar, scroll down to "Elastic Block Store" and click on "Volumes". - Find the volume named nautilus-volume. - Select the checkbox for nautilus-volume. - Click the "Actions" button and select "Attach volume". - In the Instance search box, click and select your instance: nautilus-ec2. - Device name: This is a crucial step for this task! Delete the default suggestion and type: /dev/sdb. - Click "Attach volume". - Refresh your Volumes list. The state of nautilus-volume should now be "in-use". - Go to the EC2 Dashboard, select nautilus-ec2, and click the Storage tab. You should now see two volumes listed under Block devices: the root volume and your new /dev/sdb volume! - The AZ Rule: An EBS Volume must be in the exact same Availability Zone (e.g., us-east-1a) as the EC2 instance to be attached. - Device Names: In modern Linux instances, even if you specify /dev/sdb in AWS, the OS might see it as /dev/xvdb or /dev/nvme1n1. - Hot-Plugging: You can attach EBS volumes while the instance is running! - Availability Zone Mismatch: If you can't find your instance in the dropdown, 99% of the time it's because the volume and instance are in different AZs. - Forgetting to Mount: Attaching the volume in AWS is like plugging in a USB drive. You still need to log into the Linux server to format the disk and mount it to a directory before you can use it! - Device Name Confusion: Always double-check the requirements. Some legacy systems specifically look for certain device paths. - πŸ’¬ Let’s connect on LinkedIn: Are you a "GP3 by default" person or do you prefer other volume types? πŸ‘‰ Hritik Raj - ⭐ Support my journey on GitHub: Check out my repository for all 100 days of cloud tasks. πŸ‘‰ GitHub – 100 Days of Cloud