[RndTbl] Best ways to find where disk space is being used?

Brian Lowe brian2 at groupbcl.ca
Mon Feb 6 00:36:53 CST 2023


On Sunday, February 5, 2023 2:56:04 P.M. CST Chris Audet wrote:
> I've got a fairly long lived CentOS server that stubbornly stopped
> installing updates because the HDD is full.
> 
> Can someone share their favourite way to determine where disk space is
> being used up on a system?
> 
> For example, on Windows I'd use Wiztree/Treesize/Windirstat.  On Linux
> desktop I've been using Gnome Disk Usage Analyzer (aka Baobab)
> <https://wiki.gnome.org/Apps/DiskUsageAnalyzer>.
> 
> But I'm not sure what the best solutions are in cases where there's no GUI
> available.  I could always mount / over SSH and use Baobab to crawl the
> remote filesystem, but that seems less than optimal 🤔

I use this method from the command line. As root, `cd /` and issue the following command:

find . -maxdepth 1 -type d 2>&1 -print0 | grep -zv '^\.$' | xargs -0 du -sm | sort -rn | more

The directory with the greatest usage appears first. `cd` into it and issue the
above command again. Clean directories and large files, then repeat as needed.


Two things to note:

1. Some programs in Linux do a trick where they allocate a file and then delete it while keeping 
the file open. The inode remains busy and the space isn't freed up until the process terminates. 
The advantage to this is other processes can't open the file to look into its contents. The 
disadvantage is you can't see the file using 'ls'. However, such files show up in 'lsof' with the tag 
'(deleted)'.

2. A file system can report "full" if it runs out of inodes. This used to be a problem on old, small 
systems, but probably isn't any more because file systems today tend to be very large and have 
loads of spare inodes. The command "df -i" shows the inode counts.

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://muug.ca/pipermail/roundtable/attachments/20230206/93f58b05/attachment-0001.htm>


More information about the Roundtable mailing list