Interview Prep/Linux/Disk space, inodes and filesystems

`df -h` shows `/` at 100%, but `du -sh /` only adds up to 12 GB on a 50 GB disk.

IntermediateTroubleshootingDisk space, inodes and filesystems
Answer

Likely causes → A deleted file is still held open by a process (often a log deleted with rm while the app writes to it), or data is hidden under a mount point.

Diagnose →

sudo lsof -nP +L1 | sort -k7 -n | tail      # NLINK 0 = deleted but open
sudo lsof -nP | grep '(deleted)'

Fix → Restart or reload the process holding the file so it releases it. If you can't restart, truncate through the fd: sudo truncate -s 0 /proc/<PID>/fd/<FD>.

Prevent → Rotate logs with logrotate (postrotate signal or copytruncate), never rm active logs.

All Linux questions Roadmap: Linux

More on Disk space, inodes and filesystems