1

I love this piece of software ncdu; I also have it installed on all my servers. But imagine a cozy Saturday evening ruined by an alert from Grafana that says one of your servers uses more than 95% of disk capacity. You suddenly rush to your workstation, switch your browser to work profile, and ssh to your machine without knowing what the reason behind this high disk usage is. You are distressed and rely on your comfy buddy ncdu, but the problem is much more complicated. You can't find the files in common folders on the server. Naturally, you do a ncdu / only to witness it scan /proc for the whole time it took for me to write this question.

So my question is, if someone would want to contribute to the ncdu source code, what locations come to mind and are meaningless to scan for disk usage?

0

1 Answer 1

4

Why ncdu scans meaningless locations

Because (like any program) ncdu does what you tell it to do, not what you want it to do. By invoking ncdu / you tell ncdu to (try to) scan / and everything below it. It so happens /proc is below /.

if someone would want to contribute to the ncdu source code, what locations come to mind and are meaningless to scan for disk usage?

Already done, at least for Linux; already documented. See the --exclude-kernfs option:

--exclude-kernfs
(Linux only) Exclude Linux pseudo filesystems, e.g. /proc (procfs), /sys (sysfs).

The complete list of currently known pseudo filesystems is: binfmt, bpf, cgroup, cgroup2, debug, devpts, proc, pstore, security, selinux, sys, trace.

(Source: man 1 ncdu.)

But you need to tell ncdu this is what you want:

ncdu --exclude-kernfs /

In practice, when a server "uses more than 95% of disk capacity", you should be interested in filesystem(s) living on this particular disk, not in all filesystems, in particular not in filesystems on other disks. For this -x is helpful:

-x
Do not cross filesystem boundaries, i.e. only count files and directories on the same filesystem as the directory being scanned.

(Ibid.)

You must log in to answer this question.

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