Reproduction
I just tried the same command as you: du -sh /mnt/c/Program\ Files/
and mine reported properly with what Windows reported.
It's possible it was a bug and has been patched, or that there's something about your file system that I do not have going on with mine. You've already done a dig on linking/shortcuts, but maybe there's still something being overlooked there?
I did double check against Bash on Ubuntu on Windows
"WSL Legacy" and Ubuntu
, both reported the same for me.
Just saw the comments on the question about a reported bug, looks like everything mentioned has been patched up ?
Additional Steps to Try
You probably no longer have this issue occurring, given this was asked over a year ago now. Here's some additional steps I would try, to pinpoint where that large number is coming from.
Install NCDU
I would recommend trying ncdu
. You can install it with the following on Ubuntu/WSL[Ubuntu Flavor]:
sudo apt install ncdu
This will crawl your system and visually show you where space is going. This may help you pinpoint what/where the disk is supposedly being used in that program file mount. I would be really interested to see if this shows the same issue or not. I assume ncdu
uses du
so I would think it would display the same for you unless it uses some flags behind the scene to avoid this.
Display Usages Only for Program Files Directory
Using ncdu
to crawl only a specific directory is pretty straight forward. You can display usage only for the Program Files
directory on windows using the following command:
ncdu /mnt/c/Program\ Files
Resolution
I would recommend that you use Windows to determine disk usage for the Windows Operating System, especially given that the file system is undoubtedly NTFS.
If you want to determine the disk usage just in the WSL instance I would recommend using ncdu
and ignoring the /mnt
directory so you only display usage for the Linux system and not the Windows mount.
Don't get me wrong though, my interests are equally piqued about what's going on with your situation.
Check Linux Disk Space Ignoring Windows Mount
To check the Linux disk usage ignoring the windows mount you can run:
ncdu --exclude /mnt
Why Small Files Take Up More Data
If I recall correctly, even if you only throw a couple of characters into a text file, you're still occupying the sector on the drive. Double checking I was not able to reproduce this on NTFS drive systems, but I was able to do this on FAT32. NTFS is used for Windows so it's possible the reporting through Linux is displaying through Linux's interpretation of the filesystem that it's working with.
It used to be that some apps would make thousands of small files, and it was like death by a million paper cuts. Also transferring thousands of small files would take much longer than a single large contiguous file.
Note that you can see its actual size and the size it occupies on the disk.
I doubt this is the reason you're seeing a large discrepancy in your disk reporting though, but it could be interesting if you had millions of small files. Some caching/storage schemes do tend to branch out into many small files for quick binary search access.
Best Answer
Here is a script displaying a human readable directory size using Unix standard tools (POSIX).
eg: