π Scaling without Stopping: Expanding EBS Volumes on the Fly
Hey Cloud Architects π
Welcome to Day 50 of the #100DaysOfCloud Challenge!
Today, we are solving a common production headache: a server running out of disk space. The datacenter-ec2 instance is hitting its limit, and we need to increase its storage from 8 GiB to 12 GiB. Weβll be performing a "hot" expansion modifying the infrastructure in the AWS Console and then extending the filesystem via the CLI all without a reboot.
This task is part of my hands-on practice on the KodeKloud Engineer platform, which is perfect for mastering Linux storage management.
π― Objective
- Identify the Elastic Block Store (EBS) volume attached to
datacenter-ec2. - Modify the volume size in the AWS Management Console from 8 GiB to 12 GiB.
- SSH into the instance using the provided
.pemkey. - Use Linux CLI tools (
growpartandresize2fsorxfs_growfs) to reflect the new size in the root partition.
π‘ Why Online Expansion?
In a traditional data center, adding storage often meant downtime, mounting new drives, or complex RAID re-configurations. With AWS EBS, the physical hardware change is virtualized. However, increasing the "container" size (the volume) doesn't automatically grow the "room" inside (the partition and filesystem). We must manually tell the OS to use the newly available space.
πΉ Key Concepts
- Elastic Block Store (EBS): Scalable block-level storage volumes for EC2 instances.
- Volume Modification: The AWS API action that changes the block device size.
- Partition vs. Filesystem: The partition is the "slice" of the disk, while the filesystem (like ext4 or XFS) is the actual data structure inside that slice. Both must be expanded.
π οΈ Step-by-Step: Storage Workflow
πΉ Phase A: AWS Console Modification
First, we tell AWS to increase the physical allocation of the block device.
-
Find Volume: Navigate to the EC2 Dashboard, select
datacenter-ec2, and click on the "Storage" tab to find the Volume ID.
- Modify Volume: Go to Volumes, select the ID, click Actions > Modify Volume.
-
New Size: Change the size from
8to12GiB and click Modify. - Status: Wait for the volume state to show "in-use - optimized" (though you can proceed while it's optimizing).
πΉ Phase B: Connect to the Instance
Now we move to the command line to finalize the change within the OS.
-
SSH Command: Use the key located at
/root/datacenter-keypair.pem.
ssh -i /root/datacenter-keypair.pem ubuntu@<EC2_PUBLIC_IP>
-
Verify Block Device: Run
lsblkto confirm the OS sees 12GB at the disk level but still shows 8GB at the partition level.
πΉ Phase C: Expanding the Partition (CLI)
We must extend the partition to fill the new 12GB of space.
-
Grow Partition: Use the
growpartcommand on the root disk (usually/dev/xvdaor/dev/nvme0n1).
sudo growpart /dev/xvda 1
-
Verify: Run
lsblkagain. You should now see the partition size has increased to 12G.
πΉ Phase D: Expanding the Filesystem (CLI)
The final step is to stretch the filesystem into the new partition space.
-
Check Filesystem Type: Run
df -hTto see if it isext4orxfs. - Resize (for ext4):
sudo resize2fs /dev/xvda1
- Resize (for XFS):
sudo xfs_growfs -d /
β Verify Success
-
Disk Usage Check: Run
df -hand confirm that/now shows a total size of 12 GiB. - Service Health: Ensure your application is still running without issues.
π Key Takeaways
- π No Reboot Needed: Modern Linux kernels and EBS volumes support live resizing, which is critical for 24/7 operations.
- π‘οΈ Snapshot First: In production, always take an EBS Snapshot before modifying a volume, just in case something goes wrong during the partition resize.
- π¦ Optimization Time: While the size change is immediate, the underlying AWS hardware may take time to "optimize" the performance of the new space.
π« Common Mistakes
-
Incorrect Device Name: Running
growparton the wrong disk or forgetting the partition number (the1in/dev/xvda 1). -
Skipping the Filesystem: Many forget the
resize2fsstep; if you skip this,lsblkwill show 12GB butdf -hwill still show 8GB. -
Permission Denied: Always use
sudofor storage commands as they require root-level access to the block devices.
π Final Thoughts
Storage management is a bread-and-butter skill for DevOps. By mastering the transition from AWS Console changes to Linux CLI execution, you ensure that your team's development environment stays performant and scalable without ever hitting a "Disk Full" wall.
π Practice Like a Pro
Want to master Linux storage and AWS EBS? Practice here:
π KodeKloud Engineer - Practice Labs
π Letβs Connect
- π¬ LinkedIn: Hritik Raj
- β Support my journey on GitHub: 100 Days of Cloud









Top comments (0)