Stop ignoring the difference between disk space and file space
Disk & Filesystem Management (Du/Df/Lsblk/Fstrim)
Stop ignoring the difference between disk space and file space
🧩 The Challenge
You stare at the output of df -h and see a partition is full, but when you run du -sh on the mount point, the numbers don’t add up by gigabytes. I spent half a Saturday tracking down a massive deleted log file that a background process was still holding open, and it wasn’t a fun time.
💡 The Fix
Use lsof to spot those deleted files that are still sucking up disk space because a process refuses to let go of the file descriptor. You’ll see the true culprit immediately once the list filters by deletion status.
sudo lsof +L1
⚙️ Why It Works
Files that have been unlinked but are still held open by a process don’t disappear from the disk, so df keeps counting them while du ignores them. Running this command shows you exactly which process needs a restart to finally release that occupied space.
🚀 Pro-Tip: If you can’t restart the process, try truncating the file to zero size instead of killing the app: true > /proc/[pid]/fd/[file_descriptor]
Linux Tips & Tricks | © ngelinux.com | 7/20/2026
