In this blog post , We will learn to resize EBS volume without rebooting EC2 instances.
What is EBS Volume?
Amazon EBS volume is a durable, block-level storage device that you can attach to a single EC2 instance.
It is a block storage system which is used to store persistent data.
Amazon EBS – Volume Types:
- General Purpose SSD
- Provisioned IOPS SSD
- Throughput Optimized HDD
This article guides you to resize the EBS volume size without rebooting the EC2 Instance.
Modifying Volume Size Using AWS Console:
Login to EC2 management Console,
Choose Instances in the last pane
Select the instance for which you want to resize the Volume.
Under Description , You should see the Root device attached with the EC2 instance.
If you click the volume , You should see the following pop up,
Select the EBS volume ID , It will take you to Volumes page.
Under Actions , click Modify,
Change the size of the volume, It should be above 200GB and Click Modify.
Important Note: EBS Volume once increased, It cannot be reduced.
Resizing the Partition:
Now login to the EC2 instance for which we have modified the Volume size.
Now list the block devices attached with this instance using the below command.
[email protected]:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop1 7:1 0 89.1M 1 loop /snap/core/8268 loop2 7:2 0 240K 1 loop /snap/jq/6 loop3 7:3 0 89.1M 1 loop /snap/core/8213 xvda 202:0 0 250G 0 disk └─xvda1 202:1 0 200G 0 part /
You can see that, I have change my volume size from 200 to 250 But still its 200 GB, Lets go ahead and change it.
Installing the tool:
We have to install a package named cloud-guest-utils which will help us to resize the volume.
Install the package using the below command,
apt-get install cloud-guest-utils
Once the package is installed.
Extend the partition using growpart:
growpart is used to extent the patition in the partition table if any free spaces are available.
Run the below command,
growpart /dev/xvda 1
You should see the following output:
CHANGED: partition=1 start=2048 old: size=419428319 end=419430367 new: size=524285919,end=524287967
To extend the file system , Run the below command.
xfs_growfs -d /
Let’s check the partition size:
[email protected]:/home/rahulk# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop1 7:1 0 89.1M 1 loop /snap/core/8268 loop2 7:2 0 240K 1 loop /snap/jq/6 loop3 7:3 0 89.1M 1 loop /snap/core/8213 xvda 202:0 0 250G 0 disk └─xvda1 202:1 0 250G 0 part /
Now you can see that the /dev/xvda1 partition is increased from 200 GB to 250 GB without Rebooting the Instance with Zero Downtime.
Thanks for reading this article.
Please do checkout my other articles.