Tech Blog

Cloud Computing

Extend disk for Linux Instances on AWS without a reboot

By Sabya Sachi3 min read
← Back to blog

For Linux instances running on AWS, we can resize the EBS volume in use with a guaranteed zero downtime. This comes in handy as most Linux instances are prompted with 8 GB storage as default. When applications running or generating logs for specific use cases, this default storage runs out very quickly. The resizing procedure should not affect any application operation in progress. Below is the step by step guide.

Step: 1 – Resize Boot volume

Log in to AWS console and select your Linux machine. Now follow the below navigation and change the volume size from 8 to 20 GB or whichever value we need.

Scroll down and locate the Root/Block Device/volume info under the Instance description. Now Click on the Volume which generally is denoted by “/dev/xvda”. We can first click and then right-click on the EBS ID to open the specific volume in another tab for easy operations. Now that we have the volume in front of us, click Actions> Select Modify Volume> Edit Required Size in GB> Click Modify. Now we should confirm that we want to grow the disk and we would receive a success message.

Step: 2 – Log in to the Instance via SSH and extend partition.

We should now SSH into our Linux Instance using a tool of preference & keypair and check the below details about our Instance.

Command- df -ht This lists out file system for each volume. For example: We can find both boot and additional volume with an XFS file system. The naming convention /dev/nvme(0-26)n1 means that our volumes are exposed as NVMe block devices.

Command- lsblk This helps us check if our volume has a partition that we must extend. Here we can clearly see that our root volume, /dev/xvda, has a partition, /dev/xvda1. While the size of the volume is 20 GB, the size of the partition is still 8 GB and must be extended.

Command- sudo growpart /dev/xvda 1
or sudo growpart /dev/xvdf 1 Depending on the partition. Notice that there is a space between the device name and the partition number. This command will extend the partition.

Reuse the following commands to verify-
lsblk : partitions reflect the increased volume size
df -h : size of the file system for each volume

Command- sudo xfs_growfs -d /
or sudo xfs_growfs -d /data Depending on the partition. Note that  / and /data are the volume mount points shown in the output for df -h. We can also use the same df -h command again to verify that each file system is reflecting the extended volume size correctly.

Bonus Points-
If our instance does not have XFS tools installed, we can use: sudo yum install xfsprogs
If our volume is ext4, we should use resize2fs command: sudo resize2fs /dev/xvda1

Reference Links- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

Keep reading

You may be interested in

Browse all articles →
How to Configure AWS CLI?
December 30, 20224 min read

How to Configure AWS CLI?

In Cloud platforms such as AWS, GCP, and Azure we have multiple ways to access cloud services and our resources like GUI (Console), CDK, and CLI. In today’s blog, we are going to look at CLI access in AWS. Like all other cloud providers, AWS also provides CLI access to their services for that first […]

By Keerthik ShenoyRead More →
AWS Automation with Python Boto3
December 30, 20223 min read

AWS Automation with Python Boto3

Automation plays a major role in In Cloud and DevOps, we have many tools to automate manual processes like Infrastructure automation with Terraform, for CICD Jenkins, GitLab, AWS, code pipeline, etc. In the same way, we can automate some of the AWS tasks with a simple python script using the oto3 library. Let’s see some […]

By Keerthik ShenoyRead More →
AWS Cost Optimization Techniques
December 15, 20224 min read

AWS Cost Optimization Techniques

AWS is the world’s leading cloud computing platform, providing a wide range of services including computer computing, storage, networking, and platform as a service (PaaS). AWS cost optimization requires identifying areas for cost-saving measures, tracking your usage, and putting advice into practice. Your Amazon costs are largely influenced by the cost of EC2 instances provided […]

By Keerthik ShenoyRead More →