Interview Prep/Linux/Disk space, inodes and filesystems

`du` and `df` disagree by 20 GB and `lsof +L1` shows nothing. What else could hide the space?

AdvancedTroubleshootingDisk space, inodes and filesystems
Answer

Likely causes → Files written into a directory before a filesystem was mounted on top of it, reserved blocks, or snapshot/metadata space.

Diagnose →

sudo mkdir /mnt/rootonly
sudo mount --bind / /mnt/rootonly
sudo du -xsh /mnt/rootonly/{var,data,srv,mnt} 2>/dev/null
sudo tune2fs -l /dev/nvme0n1p1 | grep -i 'reserved block'

Fix → Delete or move the hidden files seen through the bind mount, then umount /mnt/rootonly. For a data disk, reduce reserved blocks: tune2fs -m 1 /dev/sdb1.

Prevent → Use nofail and monitor that data mounts are actually mounted, so apps don't silently write to root.

All Linux questions Roadmap: Linux

More on Disk space, inodes and filesystems