MacOS – Free space on hard drive going up and down too much

hard drivemacos

On my laptop with macOS Sierra 10.12.5 (but it was happening with previous versions of the OS too), I get pinged by the system that I have only a few GBs left, I clean up, reboot, go from 4 GB left to 30 GB left, and within a couple of days, not doing anything special (not downloading movies or anything space-hungry), I get told again I have only 4 GB left … I went through that cycle a few times now, and I'm wondering what could be causing that behavior, and how I could stop it. Any idea or pointers to what I should look at on my HDD to try and understand this? (sleep images, sparse bundles…)

Note: this question is not about using a disk inventory app to find the large files that take up too much space on my HDD. What I am interested in is why I got from 30 GB after boot to 4 GB without installing anything on my Mac. I want to understand which process is doing that and stop it.

Best Answer

To get a convenient du-diff tool, install brew which requires Command Line Tools (CLT) for Xcode or Xcode, from within brew links (brew install links) and finally download and unzip gt5.

gt5 is a shell script which can either be run directly from its current dir or you can move it to a directory in your PATH (echo $PATH). Make the script executable if necessary.

Make a temp gt5 dir: mkdir ~/.gt5-diffs Run the script with:

sudo ~/Downloads/gt5-mac/gt5 / --cut-at 0.01 --max-depth 10 --diff-dir ~/.gt5-diffs

After running the script two times with a ∂t of eight minutes I get the following result:

 gt5 v1.4.0 (host:/):   [cut:0,01% depth:10 lines:10000]                                                                 
  last check was on Mo Jun 12 19:40:13 CEST 2017 (i.e. 0d, 00:08:10 ago)                                                             

     ---------------------------------------------------------------------------------------------------------------------------     

 ./:   [221GB in 11 files or directories]  +708KB                                                                                    

  176GB [79,35%] ./Share/                                                                                                            
   16GB [ 7,01%] ./Applications/                                                                                                     
   15GB [ 6,93%] ./Users/  +568KB                                                                                                    
  4,8GB [ 2,16%] ./System/                                                                                                           
  3,6GB [ 1,64%] ./Library/                                                                                                          
  3,5GB [ 1,59%] ./private/  +140KB                                                                                                  
  2,5GB [ 1,13%] ./usr/                                                                                                              
  386MB [ 0,17%] ./opt/     

After modifying the gt5 options (e.g. increase depth and/or lines)/dir and running the script several times you will get the culprit eating your disk space.

Due to the limitation of the --cut-at option to 0.01, folders with a size smaller than 0.01 percent of the total size of the superior folder aren't shown. In the above example that's / with 221 GiB: folders in the root folder with a total size smaller than 22.1 MiB won't appear (the sizes are base2 and not base10!). --cut-at defaults to 0.1 and can be adjusted between 0.01 and 30.