How to find the biggest directories in my hard drive?
I logged into my server this morning and received a disk is full
error. How do I fix this or find wherever all of this data is hiding?
Well, the first thing you want to do is try to login as root (recovery mode).
EDIT: If you are in recovery mode, you'll need to remount as RW. To do this, mount -o remount,rw /
.
Run cd /
. This allows you to enter the root and begin to trace the problem.
When you are in /
, run du -sh *
. This'll give you a list of all of the files in your hard drive. Let's say you see
2.6T var
You know that the problem is in /var
. You then cd /var
and run the du -sh *
command again. Scroll and look for something like
2.6T zpanel
You then know the problem is in the ZPanel folder. (I am using ZPanel for this example, as I just recovered from this exact problem). By now you know the drill. You cd zpanel/
and du -sh *
. Look for something like
2.6T backups
Same old, same old. cd backups/
, du -sh *
. But this time, you get
(size) zpanel_date_etc
The backups
folder contains no more subdirectories, so you expunge the unnecessary files. In my case, I used rm -rf zpanel_*
and went from 100% capacity to 25% capacity.
Then, you fix wherever the problem is. (For me, it's in ZPanel's backup settings, so I should change those).
This works with any situation, all you need to do is trace the problem.
N.B. I know you could have probably used a sort
to do this, but if you have no temp space, you can't sort
. This is the best option.