mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
[GH-ISSUE #444] Handle deleted files on Linux #193
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tatref on GitHub (Oct 14, 2024).
Original GitHub issue: https://github.com/bootandy/dust/issues/444
Hi,
On Linux, if a file is deleted while a process still has a handle on it, the disk space is still used, but not visible on the FS (ls, find.. will not find it). This is a common sysadmin issue, so I think it would be great to add an option to search for deleted files
The only way to know that a file is still taking up space, is by walking the file descriptors under
/proc/$pid/fd/, and checking if the files still exist.We can use
lsofto show the deleted files:Do you think it would be a worthy feature to add to dust?
@bootandy commented on GitHub (Oct 18, 2024):
That is an interesting edge case.
I can imagine this being a common problem for sysadmins.
dust works by walking thru the filesystem, if
lswon't find it I don't think dust will.I'm currently not keen on adding this feature. Like you said, it would require walking the file descriptors, checking if that path matched the path dust was run for, then working out if it had already been included. Then if I were to show it I'd need a way of marking it as 'different' because it wouldn't be removed if you 'rm' the file.
I think we are probably better served with
lsof -n | grep deleted@tatref commented on GitHub (Oct 18, 2024):
Yes you are correct, dust or ls can't find the file with a syscall in the filesystem, the only way is through /proc/
The workflow you describe is what I imagined. Yes
rmcan't delete the file, but the space is still used on the FS. We could maybe add a flag--list-deletedor something, then display the file deleted files as others. Or don't add a flag, and list the file with a different color/patternThe thing is, using
lsofcan be complicated: the size shown is not the used space on the FS (it does not take into account sparse files), same file can be listed multiple time... Also there is no easy way of grouping the files by dir, as with dust.I can help to make a demo implementation if you want
@bootandy commented on GitHub (Oct 21, 2024):
If you were to have this
--list-deletedflag. Do you think you would want it to be merged in with the regular files. Because I'm wondering if it should ONLY show the deleted files.If you are hunting down lost disk space your procedure for actual files in the filesystem is going to be different than for processes that are holding on to deleted files.
So I'm proposing this:
What do you think about this ?
@tatref commented on GitHub (Oct 24, 2024):
Hi,
I think it's better to merge the deleted files with the regular files, because in the end, both are taking up space.
The name of the deleted files are suffixed by the kernel with
(deleted), so if theses files are visible in the output (not too deep in the tree), they will be visible like so:If you want to test, you can do the following:
@bootandy commented on GitHub (Jun 5, 2025):
i think this is too niche so I'm closing it.