Dealing With Disk Hogs
Some users and application developers believe that any free disk space on the server belongs to them. Suddenly you get an email alert saying that a server “xyz” ran out of disk space in /home. You need to take care of this quickly, otherwise user sessions and applications may start crashing. Even if you have no more disk space to give them, there are a few things you can do to temporarily correct the problem.
The first step is usually to check for large files that were recently modified. The command below will find all files in /home that were modified in the past two days and that are larger than 10Mb. The results will be sorted by file size, with largest files at the top.
find /home -type f -mtime -2 -size +10240k -exec ls -als {} \; | sort -rn
Now you can contact the guilty users and tell them to clean up their junk. Or else. If you can’t get a hold of the file owners, the best way is to move these large files elsewhere and put a soft link to the new location. Make sure to preserve ownership and permissions when you move the files, to ensure that users can access them at the new location. Alternatively, you can just compress the files in place (if you still have enough disk space) and notify the users.
The next step is to see if there are any recent core dumps left behind by user applications:
find /home -type f -mtime -2 -name "core" -exec ls -als {} \; | sort -rn
If you don’t need any of them, then you can easily remove them:
find /home -type f -mtime -2 -name "core" -exec rm {} \;
But what if the problem is being caused not by a few huge files, but by a whole bunch of small ones? It’s a good idea to get the break down of filesystem space utilization by top-level directories. This way you can see if any particular folder is eating up an unusually large chunk of disk space:
find /home -type d -maxdepth 1 -exec du -sh {} \; | sort -rn | grep -v "/home$"
This will give the list of directories in /home sorted by the amount of space they use. Now you can pick the largest ones and concentrate your attention there.
You can find more information on dealing with out-of-disk-space situations here.
Popularity: 2% [?]
Related posts:


