MacOS Sierra – How to Find What is Using All Disk Space

disk-spacehard drivemacos

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?

Best Answer

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
...