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:
Create an EC2 Instance 🖥️
Modify the Root Volume 🛠️
Resize the Partition and File System 🔧
🛠️ Step 1: Create an EC2 Instance
First, let’s spin up a new EC2 instance. Follow these steps:
Navigate to the EC2 Dashboard: Head to your AWS Management Console and select the EC2 service.
Launch a New Instance: Click on “Launch Instance” to start the creation process.
Name Your Instance: Give your instance a name, such as “EBS Volume”.
Choose an Amazon Machine Image (AMI): I’m using an Ubuntu image here.
Select an Instance Type: For testing purposes, you can choose a “T2 Micro” instance.
Configure Network Settings: Switch from a private to a public subnet and enable auto-assign public IP.
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:
Go to the Volumes Section: In the AWS Management Console, navigate to the EBS section under “Elastic Block Store”.
Select the Volume: Find the 8 GB root volume attached to your instance.
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
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:
Connect to Your Instance: Use SSH or the AWS terminal to connect to your instance.
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.
Verify the File System: Use
df -h
to check the file system size.df -h
Resize the Partition:
For resizing the file systems, use the
file -s
command to know it's filesystem.sudo file -s /dev/xvda1
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
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
orxfs_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! 🌟