I run this website on a t2.micro EC2 instance. It only has 8 gigabytes of storage space. The blog runs on WordPress. I tried creating a new post recently, but it wouldn’t let me publish.
A vague message told me I was “editing the page that shows your latest posts” – even though I wasn’t. I checked the dashboard site health, and noticed that somethings needed updating, but disk space was critically low.
I SSH’d into the instance was able to confirm that 100% of the 8 gigabytes was in use: `df -h`
I was able to use the ‘disk usage’ command to drill down and find large directories: ‘sudo du -h –max-depth=1 /var’. I was able to clean up unused yum packages, logs, and cache to clear up over a gigabyte of space.
sudo journalctl --vacuum-size=100M sudo yum clean all rm -rf /var/cache/yum
It looks like there are some database files that could be cleaned up too, but I’ll wait for now. I think my next course of action, when this inevitably happens again, will be to increase my disk space by expanding my EBS volume and resizing the file system.
Playing with databases and storage can be dangerous. Make sure you always have a back-up strategy and disaster recovery plan.