Thursday, February 3, 2022

[SOLVED] Increase EC2 disk storage without losing any data

Issue

I have a t2.medium instance running, which has 4GB of RAM and 25GB of EBS volume.

This instance is currently running a Apache server, a wordpress app, mysql server and a codeigniter app.

I don't want any data to be lost.

How can I increase the volume to 100GB?

I found an article here , but I am not sure if doing so will cause all the data be lost.


Solution

we can increase ebs volume without detaching the volume or restarting the instance. Its good to create a snapshot of your ebs volume in case if something bad happens

for creating snapshot

Go to your EBS volume list from your EC2 Dashboard.
Right click the volume.
Click Create Snapshot link.
Add the description value any thing is good here.
Add key : Name and value : snapshot-your-volume.
Click button Create Snapshot.

to increase size

Right click on the volume you wish to increase.
Add your desired size; In our example type 40.
Click Modify.
You will get confirmation to extend OS file system.
Click Yes.

once you finish modifying volume, you need to extend OS file system in order to see the increased volume size.

ssh into your instance 
df -h -> will tell you the volume size
lsblk -> display information about the block devices attached to your instance
sudo growpart /dev/xvda 1
df -h -> to verify the size again
sudo resize2fs /dev/xvda1

docs for extending filesystem



Answered By - Jatin Mehrotra
Answer Checked By - Katrina (WPSolving Volunteer)