Interview Prep/Linux/Disk space, inodes and filesystems

`rm -rf` on a directory reports `Directory not empty` even though `ls -la` shows nothing inside.

AdvancedTroubleshootingDisk space, inodes and filesystems
Answer

Likely causes → Something is mounted inside it, a process keeps creating files, or (on NFS) .nfsXXXX silly-rename files for files still open on a client.

Diagnose →

findmnt -R /path/dir
ls -la /path/dir; sudo lsof +D /path/dir

Fix → Unmount nested mounts, stop the writing process, or close the files on the NFS client (the .nfs* files disappear afterwards). Then retry.

Prevent → Stop services before cleanup; avoid deleting files still in use on NFS.

All Linux questions Roadmap: Linux

More on Disk space, inodes and filesystems