How I Clean Up AWS EC2 Storage For Not Getting It Full

Today I will share my technique on how I clean up AWS EC2 storage for not getting it full. Many people using AWS Instance for hosting their website face this common problem of storage full in a few days and the website shutdowns.

So Let’s Begin To Clean Up AWS EC2 Storage.

1. First, you have to connect your AWS instance with Putty SSH. Don’t know how to do that don’t worry I will put a video which u can view and connect your AWS to Putty SSH.

The video is in Hindi if you don’t understand the language no worry just follow the steps and you are done or you can search on for your compatible language.

2. After you are connected to AWS instance using Putty SSH you will see this window.

Now we can see we are logged in as bitnami now we have to check how much storage is filled first. For that, we will use the following command.

df -h

Now you will see storage used and storage left in your instance.

As you can see my 11 GB is used from 30 GB and only 18 GB is remaining and my website size may be hardly 500 mb so who is using rest of your memory you will get the answer below.

Now rest of the process can only be done by root use so we have to go as root user for that we have to the command given below.

sudo su

this command will make you log in as root user after that you will see a window like this.

3. Now after we are in the root directly we have to find the biggest file which is filling our space in most of the cases it the MySQL bin logs files which are not pruned and fill our space in my case also it’s the bin logs file which is creating an unnecessary log file of 1.1 GB every day and filling up my instance storage.

To find it enter the following command.

du -hs /opt/bitnami/*/*/* | sort -rh | head -5

-5 is the number of list file, you can replace it with your number you think your log files should be.

Now you will see the files which are big and filling your instance space. You, will see everything in detail with file size file directory and file name.

4. Now that what we have to do is check this size of the binlog folder first using this command.

du -hs /opt/bitnami/mysql/data

Now you will see the size of your binlog files folder.

As you can see my 7.5 GB is used just for the purpose of bin logging and the prune function is not working correctly.

5. So my solution is to prune it manually for that we have to go to the directly first where the files are stored. For that, we will use the following command.

 cd /opt/bitnami/mysql/data

6. Now we have entered the following directory we list all the file present in the directory. For that we will use the following command.

ls -h

Now you can see all the binlog file present in the folder which is using you instance space unecessarily.

7. So now we have to prune(delete) it manually. We will only delete the old binlog files leaving 2 latest file.

Warning: Please make a backup of your website before practising this method this technique worked for me but cannot guarantee will work for everyone so before you apply this technique to yours make sure you backup your site.

Now we will use the follow command to delete the files.


Now after command enter the file names you wanna prune(delete) in my case it is binlog.000004 to binlog.000011 and will leave the latest two binlogs and prune rest.

Now lets check our storage again after prune.

As you can see previous my used storage was 11 GB and now it just 5.1 GB, 3.1 GB is used by system rest is used by our website.

So this way we can clean up AWS EC2 storage in we steps. Just do it ones in a week and thats all your site will never face the storage full issue.

If you like this article make sure you subscribe so that you dont miss our latest post.

For more such articles you can visit “Computer & Technology“.

10 thoughts on “How I Clean Up AWS EC2 Storage For Not Getting It Full”

  1. Of course, what a fantastic blog and instructive posts, I surely will bookmark your website. Have an awsome day! Etti Mattias Flatto

  2. Attractive section of content. I just stumbled upon your site and in accession capital to assert that I get actually enjoyed account your blog posts. Aundrea Sonnie Eric

  3. Excellent article! We will be linking to this particularly great article on our website. Keep up the good writing.| Agace Andrey Downs

  4. Hello there. I discovered your web site by the use of Google whilst searching for a comparable topic, your site got here up. It seems good. I have bookmarked it in my google bookmarks to come back then. Mariel Pernell Damian

  5. I have recently started a site, the information you provide on this web site has helped me tremendously. Thank you for all of your time & work. Jerrilee Karlan Kancler

  6. I was pretty pleased to discover this website. I need to to thank you for ones time for this fantastic read!! I definitely loved every little bit of it and I have you saved to fav to check out new things in your site. Deena Clair Rusel

  7. The article was really helpful, can you also do a post on automatically purging the binlog, so that manually deleting is not required ?


Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.