<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="" dir="auto">There's a shell trick I stumbled upon years ago to simplify that: filename globbing will only include directories if you have a trailing slash.</div>
<div style="" dir="auto"><br>
</div>
<div style="" dir="auto">So "du -sm */ | sort ..." usually gives the same result as the find pipeline.</div>
<div style="" dir="auto"><br>
</div>
<div style="" dir="auto">I have run into situations where it didn't, and this is one 'feature' I've never felt the need to fully explore & understand, so very much YMMV.</div>
<div style="" dir="auto"><br>
</div>
<div style="" dir="auto">I also have a vague<span> recollection that the shellglob way also has some corner cases with spaces or control characters</span><span style="font-size: 12pt;"> in the directory names, that the find (1) approach handles better.</span></div>
<div style="" dir="auto"><span style="font-size: 12pt;"><br>
</span></div>
<div style="" dir="auto"><span style="font-size: 12pt;">Quick'n'dirty, not necessarily "best", but sometimes useful.</span></div>
<div style="" dir="auto"><span style="font-size: 12pt;"><br>
</span></div>
<div style="" dir="auto"><span style="font-size: 12pt;">-Adam</span></div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div><br>
</div>
Get <a href="https://aka.ms/AAb9ysg">Outlook for Android</a>
<div id="mail-editor-reference-message-container" dir="auto"><br>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" style="font-size: 11pt;"><strong>From:</strong> Roundtable <roundtable-bounces@muug.ca> on behalf of Brian Lowe <brian2@groupbcl.ca><br>
<strong>Sent:</strong> Monday, February 6, 2023, 00:37<br>
<strong>To:</strong> Continuation of Round Table discussion <roundtable@muug.ca><br>
<strong>Subject:</strong> Re: [RndTbl] Best ways to find where disk space is being used?<br>
</div>
<br>
<meta name="qrichtext" content="1">
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
On Sunday, February 5, 2023 2:56:04 P.M. CST Chris Audet wrote:</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> I've got a fairly long lived CentOS server that stubbornly stopped</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> installing updates because the HDD is full.</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> Can someone share their favourite way to determine where disk space is</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> being used up on a system?</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> For example, on Windows I'd use Wiztree/Treesize/Windirstat. On Linux</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> desktop I've been using Gnome Disk Usage Analyzer (aka Baobab)</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> <https://wiki.gnome.org/Apps/DiskUsageAnalyzer>.</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> But I'm not sure what the best solutions are in cases where there's no GUI</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> available. I could always mount / over SSH and use Baobab to crawl the</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
> remote filesystem, but that seems less than optimal ðŸ¤”</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
I use this method from the command line. As root, `cd /` and issue the following command:</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'DejaVu Sans Mono'">find . -maxdepth 1 -type d 2>&1 -print0 | grep -zv '^\.$' | xargs -0 du -sm | sort -rn | more</span></p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
The directory with the greatest usage appears first. `cd` into it and issue the</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
above command again. Clean directories and large files, then repeat as needed.</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
Two things to note:</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
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)'.</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
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.</p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="white-space: pre-wrap;margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
Brian</p>
<br>
</div>
</div>
</body>
</html>