By Anand Arun
Hi!
My site is back, but i can’t make any editions. As soon as I try to save anything, i get a 502 Bad Gateway. Looking here and there i am finding out that i am running out of disk space. How to clean it and how to avoid it being full again… something is wrong… Someone gives a hand?
sudo df -h
Filesystem Size Used Avail Use% Mounted on
udev 487M 0 487M 0% /dev
tmpfs 100M 11M 89M 11% /run
/dev/vda1 30G 30G 0 100% /
tmpfs 497M 0 497M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 497M 0 497M 0% /sys/fs/cgroup
tmpfs 100M 0 100M 0% /run/user/1000
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I had this issue for several days, here is how i fixed it:
du -a / | sort -nr | head -n 1024252620 /var
22664740 /var/log
22032628 /var/log/mysqld.log
cat /dev/null > mysqld.log
Done.
You could use a command like this to help figure out where the disk usage is coming from:
du -a / | sort -nr | head -n 10
It lists the size of all files in the / directory, sorts them by size descending, and then prints only the ten largest files (useful if a directory has a lot of files).
Based on the output, you’ll need to revise the du -a / part to check different directories - it can depend on what applications you’re using but web server, database, or log file directories are probably good places to check.
Also, if you free up enough space (or you already have it installed), ncdu is also really helpful for viewing disk usage. With a command like ncdu -x /, you can use arrow keys to move around the filesystem and view disk usage.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.