Bash – How to see disk usage with less overhead in bash

bashdisk-space-utilization

du -csh /

The above will take huge amount of time to calculate,is there a way to see the less accurate result with less overhead?

UPDATE

What I want to know is the total size under a specific directory.

Best Answer

As far as a more optimized version du, I am not aware of one. The things that come to mind are:

  1. Store these files on a ram disk or something like that.
  2. If only one application writes to this folder and its sub folder, then have the application keep track.
  3. If all these files are about the same size and evenly amount of them distributed amongst directories, you could just count the number of sub directories and multiply that by file per directory and then size per file. You could do this quickly by just using the hard link count for the directory if only you have only a one directory deep structure (stat -c '%h') - 2.
  4. Make all these files owned by a specific user and use the quota mechanism.
  5. Use a dedicated partition and just use df. A virtual filesystem (a file on a filesystem that is mounted via loopback) could do this too as well.

Out of all these, the quota and dedicated partition options are probably the easiest and most efficient.