Full filesystem without content?

Since a few days I had a problem on my Ubuntu machine that I use at home: After logging in, the system showed a warning, that /tmp was nearly full. Checking it with df -h showed that over 95% of 10 gigabyte were used. But sudo du -hs /tmp/ showed that only 5 megabyte were used by files. /tmp has it’s own partition and uses the XFS filesystem. On askubuntu.com and serverfault.com I found some promising problem descriptions and possible solutions, but none of them fit for me. Finally xfs_repair solved the problem. For this you need to unmount /tmp, so I did this:

  • Edit /etc/fstab so that the tmp-partition will not be mounted on next boot (put „#“ at the beginning of the line that mounts /tmp)
  • Reboot, /tmp is now part of the root filesystem /.
  • Call sudo xfs_repair /dev/sdxY (replace sdxY by whatever your tmp-partition is).
  • Mount the partition somewhere temporarily (for example /mnt/tmp) and check with df -h if this solved the problem.
  • Edit /etc/fstab again to reactivate the tmp-partition. Then reboot and check again.