8

My Macbook Pro has run out of disk space, and I cannot find out why.

I have minimal Applications and user data.

Output from df -h

Filesystem      Size   Used  Avail Capacity  iused   ifree %iused  Mounted on
/dev/disk1     233Gi  227Gi  5.8Gi    98% 59462769 1518477   98%   /
devfs          182Ki  182Ki    0Bi   100%      630       0  100%   /dev
map -hosts       0Bi    0Bi    0Bi   100%        0       0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%        0       0  100%   /home

As you can see here, it is reporting that I have around 6GB free space.

I then used ncdu to try get a better understanding of what was actually using the space

enter image description here

As you can see, ncdu is reporting that I have used about 30GB of space, which looks right to me.

I am obviously looking at something incorrectly here.

Any insights?

  • Before we go too far, have you run DiskUtility to see if there's simply some corruption of the Btree or other directory management files? – Carl Witthoft Dec 8 '16 at 18:53
  • I don't think your question is exactly a duplicate of this one, but you should definitely have a look as it has an extensive discussion of ways to free disk space. apple.stackexchange.com/questions/5353/… – setholopolus Dec 8 '16 at 20:04
12

Try sudo ncdu instead. As a normal admin or user you are not allowed to scan the content of certain folders (all indicated by an error while scanning and in the final listing by a dot - if a subfolder can't be scanned - or an exclamation mark - if the whole folder is excluded from scanning due to missing read permissions!).

Examples (only the big six and the .Spotlight-V100 folder are shown here):

  • ncdu:

       10,7 GiB [##########] /Applications                                                                                               
    .   4,8 GiB [####      ] /System
    .   3,5 GiB [###       ] /Library
    .   2,2 GiB [##        ] /usr
    .   1,8 GiB [#         ] /private
    .   1,1 GiB [#         ] /Users
                 ...
    !   0,0   B [          ] /.Spotlight-V100
    
  • sudo ncdu:

    .  10,7 GiB [##########] /Applications                                                                                               
        6,3 GiB [#####     ] /System
        5,2 GiB [####      ] /Library
        2,6 GiB [##        ] /private
        2,4 GiB [##        ] /usr
        1,2 GiB [#         ] /Users
                 ...
      310,7 MiB [          ] /.Spotlight-V100
    

Another nice perl hack is this command:

sudo perl -e'%h=map{/.\s/;99**(ord$&&7)-$`,$_}`du -h`;die@h{sort%h}'

It will sort all folders (not just those in the current folder) depending on size similar to Grand Perspective without bricks:

 29G    .
 11G    ./Applications
7,4G    ./Applications/Xcode.app
6,3G    ./System
5,2G    ./Library
2,4G    ./usr
1,9G    ./usr/local
966M    ./Users/user/Library
879M    ./System/Library/PrivateFrameworks
851M    ./Applications/MAMP
850M    ./private/var/db/dyld
805M    ./usr/local/mysql-5.7.11-osx10.9-x86_64/lib
778M    ./System/Library/Frameworks
...
  • indeed sudo ncdu showed me that all the space was being used by /.Spotlight-V100 – kabal Dec 13 '16 at 7:38
  • @kabal But 200 GB in the spotlight folder is really a lot. Did you rebuild the spotlight index? – klanomath Dec 13 '16 at 10:01
6

While I'm a big-enough fan of du and ncdu, sometimes it's still useful to try a GUI.

Here's Grand Perspective's output of my MBP's after-market SSD, scanned from /:

Grand Perspective scan results

I can see that Xcode.app is the largest entry in my /Applications folder, for example. (I also just found 9GB that I could free up from an old Deleted User home folder.)

2

While ncdu is excellent (and this is not a knock against it) there are a couple of built in commands you can try if you don't want to install (or can't) 3rd party utilities:

sudo du -hsx -d 1 / | sort

This command lists all files from the root directory but excludes any file system mounts (i.e. USB or network mounts) and sorts from smallest to largest. For example, issuing the command on my iMac, I get the following results:

  0B    /.Trashes
  0B    /.vol
  0B    /Network
  0B    /cores
 30G    /Applications
 64K    /Volumes
1.0K    /home
1.0K    /net
1.0M    /sbin
2.5M    /bin
234M    /.fseventsd
261G    /Users
314G    /
383M    /.cleverfiles
4.7G    /Library
478M    /.DocumentRevisions-V100
5.0K    /dev
523M    /usr
7.1G    /private
811M    /.Spotlight-V100
9.1G    /System

This gives me a nice summary of what starge the top level folders are using on my drive. In my case, the /Applications folder is consuming 30G while my /Users has 261G.

If you want to take a look at everything within your Applications folder and sort it by size, you can issue the command

sudo du -ha /Applications | sort -r

I pipe the output to sort and use the -r flag to sort it in reverse (largest to smallest) order so I can see what files and directories are taking up what space.

996K    /Applications//The Unarchiver.app/Contents/Frameworks/XADMaster.framework/Versions
996K    /Applications//Microsoft Word.app/Contents/SharedSupport/Proofing Tools/Latvian Speller.proofingtool/Contents/SharedSupport/LatvianSpeller.lexicon/Contents/Resources/LexiconData
996K    /Applications//Microsoft Word.app/Contents/SharedSupport/Proofing Tools/Latvian Speller.proofingtool/Contents/SharedSupport/LatvianSpeller.lexicon/Contents/Resources
996K    /Applications//Microsoft Word.app/Contents/SharedSupport/Proofing Tools/Latvian Speller.proofingtool/Contents/SharedSupport/LatvianSpeller.lexicon/Contents
996K    /Applications//Microsoft Word.app/Contents/SharedSupport/Proofing Tools/Latvian Speller.proofingtool/Contents/SharedSupport/LatvianSpeller.lexicon
996K    /Applications//Microsoft Word.app/Contents/SharedSupport/Proofing Tools/Latvian Speller.proofingtool/Contents/SharedSupport

The listing will be quite long, so I suggest sending the output to a text file for evaluation:

sudo du -ha /Applications | sort -r > ~/Desktop/du_results.txt

This will give you a text file on your Desktop which you can view with any text editor. This way you will have a record of what files/subdirectories you need/want to investigate as to why you are consuming so much disk space.

  • Your sorting is wonky because you have used -h, so sort treats the sizes as strings. – shoover Dec 8 '16 at 19:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .