linuxdumount-point

Linux du command without traversing mounted file systems


If the wording of the question is wrong, please let me know. It might explain why I can’t find an answer.

I want to find the usage on my main disk using a command like:

du -sh /*

The problem is that I have a number of mount points at the root level, and I would like du to skip these.

I thought the -x option was supposed to do this, but either I misunderstand what it does or I’m using it the wrong way.

How can I apply du to only the root disk without traversing the additional mounts?

Thanks


Solution

  • This is hacky, but it seems to do what you want, from the shell,

    for d in /*; do egrep " ${d} " /proc/mounts > /dev/null || du -sh ${d}; done
    

    Add a sudo in front of the du if needed.