Project: 1 How to Increase EBS Volume of an EC2 Instance on AWS Using Ubuntu
If you’re looking to increase the EBS volume on your AWS Ubuntu instance, you’re in the right place! Follow these straightforward steps:
Step 1: Change EBS Volume Size in the AWS Console
1. Navigate to AWS Management Console:
Log in to your AWS account and navigate to the AWS Management Console.
2. Access EC2 Dashboard:
From the AWS Management Console, click on “Services” and select “EC2” under the Compute section.
3. Locate the EBS Volume:
In the EC2 dashboard, select the EBS volume, you wish to resize.
4. Modify Volume Size:
Click “Actions” and then select “Modify Volume.” Enter the new volume size and click “Modify.”
Alter the size of the volume as per your requirement for my case, I’m increasing is up to 30GB.
Step 2: Extend the Partition
- Check Existing Partitions and File System Type:
Before making any changes, it’s important to know the existing partitions and their file system types. Use the following command to display this information:
df -hT
This command provides a clear view of your file system types.
“df -hT” is a command that tells you how much space is being used on your computer, “-h” shown in a human-readable format (like GB), and “-T” tells you what kind of storage system is being used (like NTFS or ext4).
From the above image, you can find the “Type” section, there my file system type is “ext4”
To check the partition, use the following command:
lsblk
This command provides a clear view of your partitions
here you can find the partition mentioned as xvda1,xvda14,xvda14 as a child of xvda.
Now I need to increase the xvda1 to 30Gb, for that I need to increase partition.
2. Extend the Partition:
To adjust the partition size to utilize the available space, run the following command:
sudo growpart /dev/xvda 1
This command ensures the partition utilizes the entire available space.
Here you can see that xvda1 is extended to my desired size.
Step 3: Extend the File System
Next, let’s extend the file system to reflect the changes:
- Check File System:
Determine your file system type to choose the appropriate command for extension. For this, use:
lsblk
This will show the file system information.
2. Extend File System (Ext4):
If your file system is Ext4 (as in this case), use the following command to extend it:
sudo resize2fs /dev/xvda1
If you have an XFS file system, the command to extend is:
sudo xfs_growfs -d /
3. Verify the Extension:
To confirm the successful extension of the partition and file system, run:
df -Th
With these steps, you’ve successfully increased the EBS volume on your AWS Ubuntu instance.
You may have doubt like what’s the difference between extending partition and extending file system, here is the layman explanation below:
Imagine your EBS volume is like a container, and your files are like items inside that container.
1. Extend the Container (Extend the Partition):
— First, you need to make the container bigger to fit more stuff. This is like making the box your stuff is in larger.
— `growpart` is the tool that helps resize the box (partition) to be bigger, so it can hold more stuff (data).
2. Fit More Stuff Inside (Extend the File System):
— Once the container is larger, you need to organize and place your stuff (data) inside the now bigger container.
— The file system (like shelves and drawers inside the box) needs to be adjusted, so it can efficiently use the extra space in the larger box.
— `resize2fs` (for some types of stuff) or `xfs_growfs` (for other types of stuff) are tools that help reorganize your stuff (data) so it fits and is easily accessible in the now larger container.
By doing these steps separately, you’re ensuring that the box (partition) is big enough to hold everything and then organizing your stuff (data) inside it effectively. It’s like making sure you have a bigger suitcase before deciding what clothes to pack!
Happy computing! 🚀