How to increase EBS storage block size on a running spot instance in AWS?

So, you created a aws group with a small ebs storage size and now that the site is in production, storage disk is full and it was mounted as root storage, now you are asking “MY AWS INSTANCE STORAGE IS FULL, WHAT TO DO?”
or “How do I increase the EBS volume size of a running instance?”

So, here is the simple solution:

There are two commands which will help you

$ lsblk

and

# df -h

So, initially if you login via SSH (using PUTTY or anything else) you will see something like this:

So, what you need to do is, you need to go to aws console and edit block size in EC2 management

Go to EBS > Volumes
Right Click the volume you need to expand and choose MODIFY VOLUME
Enter the new size you want for your block

Now run the command lsblk and df -h and you will notice the old size and new size under xvda and xvda1

Size available but not used

If you dont see the updated new size, please use init 6 or restart the instance using any other command

You now need to use utility growpart so use command


sudo apt install cloud-utils

If you are out of space, please remove any old files which are of no use anymore to free up some Mega Bytes
After that, simply use


sudo growpart /dev/xvda 1

and
sudo resize2fs /dev/xvda1
resize2fs command
lsblk after resize
df command after resize

Reference: 
https://stackoverflow.com/a/43251901/2229148


tk120404

Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *