I'm familiar with various methods of tracking disk I/O, both as a rate (e.g. bytes/second) and cumulatively (e.g. bytes) for read and write operations, however I don't know of (and cannot find) any means of tracking the amount of disk space freed by a process. I suspect this may have something to do with the complexities of defining when/how disk space is "freed".

For instance, rm file doesn't overwrite the contents of the file with some form of "nothing", but instead clears pointers and the like. In other words, it basically deallocates the disk space associated with file. But there are many other ways that disk space can be freed up. For a pre-existing non-empty file, doing echo '' >file clears its contents. Hard links and files that're opened by multiple processes potentially further complicate tracking disk usage since the definition of when/how the space is freed has some degree of ambiguity.

1 Answer 1


“Disk space freed by a process” is not a very useful concept because it's very fuzzy. If process A removes a file which is still open in process B, do you credit A for freeing the space when it removes the file (that's when the system commits to freeing the disk space), or B when it closes the file (that's when the space is actually freed)? If a file has two hard links and two processes each remove one at about the same time, is it really meaningful to credit the second one for the freed space and not at all the first one? If a process overwrites a segment of a file, does that count as freeing the overwritten data? (Does your answer change if the filesystem performs deduplication?) etc.

You could pick a definition and instrument the kernel code to keep track of it, but it would be a somewhat arbitrary choice and would have limited practical usefulness, which is why it isn't a commonly available feature. Every feature has a cost: programmer time to implement it, programmer time to maintain it later, risk of bugs that it introduces, memory and CPU consumption…

You can probably implement this (again, picking one particular definition) for common scenarios using existing debugging features such as Systemtap on Linux.

  • Funny you should use those examples. I originally had the 2nd paragraph in my (now updated) question, but decided to delete it in the hopes of avoiding getting too far into the weeds. Fortunately, I copy-pasted it into a text file.
    – TTT
    Commented Jan 9, 2017 at 3:17

You must log in to answer this question.

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