📦 Resizing and Modifying Your EBS Root Volume: A Step-by-Step Guide

📦 Resizing and Modifying Your EBS Root Volume: A Step-by-Step Guide

Hello friends! 👋 My name is Bilal Khan, and today, I'm here to guide you through the process of resizing or modifying the root volume of your EBS (Elastic Block Store). If you’ve seen my previous video on resizing EBS volumes, you might know that I focused on non-root volumes. This time, we’ll dive into resizing the root volume that's attached to your EC2 instance. Let's get started! 🚀

Here is the video explanation of it:

🚀 Getting Started

In this tutorial, we’ll:

  1. Create an EC2 Instance 🖥️

  2. Modify the Root Volume 🛠️

  3. Resize the Partition and File System 🔧

🛠️ Step 1: Create an EC2 Instance

First, let’s spin up a new EC2 instance. Follow these steps:

  1. Navigate to the EC2 Dashboard: Head to your AWS Management Console and select the EC2 service.

  2. Launch a New Instance: Click on “Launch Instance” to start the creation process.

  3. Name Your Instance: Give your instance a name, such as “EBS Volume”.

  4. Choose an Amazon Machine Image (AMI): I’m using an Ubuntu image here.

  5. Select an Instance Type: For testing purposes, you can choose a “T2 Micro” instance.

  6. Configure Network Settings: Switch from a private to a public subnet and enable auto-assign public IP.

  7. Configure Storage: The root volume is set to 8 GB by default. We will modify this later, so you can proceed with the default settings for now.

🔄 Step 2: Modify the Root Volume

Once your instance is running, follow these steps to resize the root volume:

  1. Go to the Volumes Section: In the AWS Management Console, navigate to the EBS section under “Elastic Block Store”.

  2. Select the Volume: Find the 8 GB root volume attached to your instance.

  3. Modify the Volume: Click on the volume and select “Modify Volume”. Change the size from 8 GB to 60 GB (or your desired size).

    Example Image of Modifying Volume

  4. Apply Changes: Save the modifications and wait for the changes to take effect.

🧩 Step 3: Resize the Partition and File System

Modifying the volume size in AWS is only part of the process. The partition and file system need to be adjusted as well:

  1. Connect to Your Instance: Use SSH or the AWS terminal to connect to your instance.

  2. Check the Current Size: Use the command lsblk to list block devices and their sizes.

     lsblk
    

    This command will show you the block devices and their sizes.

  3. Verify the File System: Use df -h to check the file system size.

     df -h
    
  4. Resize the Partition:

    For resizing the file systems, use the file -s command to know it's filesystem.

     sudo file -s /dev/xvda1
    
  5. Grow Partition:

    Once you know the filesystem, grow the partition.

    For ext4 filesystem, you need to use:

     sudo growpath /dev/xvda 1
    

    For xfs filesystem, you need to use:

     sudo xfs_growfs /dev/xvda 1
    
  6. Check the Updated Size: Re-run the df -h command to ensure that the file system size reflects the new volume size.

     df -h
    

🧠 Key Takeaways

  • Creating an Instance: Ensure that you configure the network and storage settings appropriately.

  • Modifying the Volume: AWS allows you to change the volume size, but you need to adjust the partition and file system separately.

  • Resizing the File System: Commands like resize2fs or xfs_growfs are essential for updating the file system to use the new space.

📈 Troubleshooting Tips

  • Volume Size Not Updating: If you don’t see the updated size, make sure you’ve resized both the volume and the file system.

  • Partition Issues: Ensure that you’ve grown the partition to cover the new volume size before resizing the file system.

I hope this guide helps you efficiently resize and manage your EBS root volume.

You can Buy Me a Coffee if you want to and don't forget to follow me on YouTube, Twitter, and LinkedIn.

Feel free to check out my previous videos for more detailed steps on creating instances and volumes. Happy learning! 🌟