Why does filesystem gradually increase by mlocate.db database ?

Environment

  • Red Hat Enterprise Linux 4
  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Issue

  • Have many mlocate.db.xxxxxx files in /var/lib/mlocate. The filesystem is currently full.
  • The date of mlocate.db is old, with the "extra" files all newer.
  • Need to know if it is safe to remove these files and run updatedb manually to free up disk space in /var.

Resolution

  • It's safe to delete mlocate.db.xxxxxx files in /var/lib/mlocate , they'll just get created from scratch next time mlocate runs.
  • If nobody is using locate command, then it can be disabled in /etc/cron.daily (mlocate.cron) so that it can avoid from the issue.
  • If the /var/lib/mlocate.db.<xxxxxx> files are all newer than the actual /var/lib/mlocate.db file, then the daily cron job is likely either being interrupted and killed or is hanging and never getting a chance to write back the temporary working file to the /var/lib/mlocate.db location.
  • Example strace of an updatedb:
    • When updatedb starts, it open a temporary working file ...
8242   open("/var/lib/mlocate/mlocate.db.hwCz3x", O_RDWR|O_CREAT|O_EXCL, 0600) = 4
  • Once it's finished, it moves it's temporary file back into the original location
8242   chown("/var/lib/mlocate/mlocate.db.hwCz3x", 4294967295, 21) = 0
8242   chmod("/var/lib/mlocate/mlocate.db.hwCz3x", 0640) = 0
8242   rename("/var/lib/mlocate/mlocate.db.hwCz3x", "/var/lib/mlocate/mlocate.db") = 0

No comments: