Question

Can't find disk space

I have a droplet that runs out of disk space very quickly and it’s not possiblt to find what is taking up the disk.

I have deleted all kinds of logs and backups, yet the disk is still 90% full even though it is almost empty according to the calculations.

It’s as if there is some ghost disk space somewhere.

df -h

/dev/vda1 25G 22G 3.0G 88% /

Yet when I calculated space at root I can only account for 8GB used

sudo du -h --max-depth=0 /

8.8G /

Any idea where the rest of my disk space could be?


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
July 17, 2023

Hello,

I would recommend starting with the following steps here:

https://www.digitalocean.com/community/questions/28-no-space-left-on-device-error

  • First check how much space you have available and which partition is filling up with the following command:
df -h

The output would look something like this:

Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G     0  2.0G   0% /dev
tmpfs           395M  1.8M  393M   1% /run
/dev/vda1        25G   20G  4.4G  82% /

In my case I am using 20G out of 25GB available for my root partition. Basically the df command reports the file system disk space usage.

  • Also if you have enough space, make sure to check your Inode usage:
df -i
  • Then depending on the partition which is filling up you could use the following command to find any files that are larger than 500MB for example:
sudo find / -type f -size +500M -exec ls -lh {} \;

The output should look something like:

-rw-r--r-- 1 root root 1.8G May 13 15:43 /home/user1/large-file.txt
-rw-r--r-- 1 root root 1.8G May 13 15:42 /home/bobby/large-file.txt
-rw-r--r-- 1 root root 1.8G May 13 15:43 /home/bobby/public_html/wp-content/core.dump
-rw-r--r-- 1 root root 1.8G May 13 15:42 /home/bobby/public_html/error_log

Depending on the size of your disk, the command might take a while to complete. You can then go ahead and delete any of the large files that you do not need.

  • If there are no large files maybe there are a lot of small files which are exhausting the available webspace, what you could do is use the du command which estimates the file space usage:
du -h --max-depth=1 /

For example:

root@bobby:~$ cd /home/
root@bobby:/home$ du -h --max-depth=1
16K ./testuser
28K ./user
16K ./root
1.8G ./user2
5.0G ./bobby
7.1G .

Then we can cd into the largest folder and run the command again:

root@bobby:/home$ cd bobby/
root@bobby:/home/bobby$ du -h --max-depth=1
76K ./.npm
4.0K ./script
5.0G ./public_html
12K ./.ssh
5.0G .

We would need to do that a few more times until we get to the folder that is using those 5GB:

root@bobby:/home/bobby$ cd public_html/
root@bobby:/home/bobby/public_html$ du -h --max-depth=1
8.0K ./test
4.9G ./wp-content
4.0K ./wpcli.bobbyiliev.com
14M ./wp-includes
7.4M ./wp-admin
16K ./node
5.0G .

Then one more time:

root@bobby:/home/bobby/public_html$ cd wp-content/
root@bobby:/home/bobby/public_html/wp-content$ du -h --max-depth=1
3.6M ./themes
252K ./plugins
4.0K ./upgrade
4.9G ./large-folder
4.9G .

And again:

root@bobby:/home/bobby/public_html/wp-content/large-folder$ du -h --max-depth=1
4.9G .

We’ve found the folder! We can see how many files are in the folder by running this command:

root@bobby:/home/bobby/public_html/wp-content/large-folder$ ls -lah | wc -l
4794

Note: if you have a database service like MySQL, make sure Not to delete any files manually from the MySQL folder. This would cause issues with your database.

If you are unable to clear any disk space I would recommend upgrading your Droplet.

Let me know if you have any questions!

Regards,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel