How to Disable/Enable Updatedb.mlocate to Reduce Disk IO
The updatedb.mlocate service is responsible for updating the mlocate database, which can sometimes consume a significant amount of disk I/O. Here, we’ll explain how to disable and enable this service as well as provide a tip for customizing which directories are indexed.
Disable updatedb.mlocate
To disable the updatedb.mlocate service, follow these steps:
-
Kill the Running Process:
1sudo killall updatedb.mlocateThis command will stop any currently running
updatedb.mlocateprocesses. -
Prevent Automatic Execution:
Disable the automatic execution of the
updatedb.mlocateservice by removing its execute permission:1sudo chmod -x /etc/cron.daily/mlocateThis step ensures that the
updatedb.mlocatescript won’t run automatically. -
Delete the Existing Database:
You can also delete the existing mlocate database to free up disk space:
1sudo rm /var/lib/mlocate/mlocate.dbDeleting the database is optional but can help save disk space.
Enable updatedb.mlocate
If you wish to enable updatedb.mlocate again, follow these steps:
-
Grant Execute Permission:
Grant execute permission to the
mlocatescript in the daily cron directory:1sudo chmod +x /etc/cron.daily/mlocateThis step allows the script to run automatically.
Customize Indexed Directories
Additionally, if you want to customize which directories are indexed by updatedb.mlocate, you can edit the configuration file /etc/updatedb.conf:
-
Open the configuration file in a text editor (e.g.,
nanoorvi):1sudo nano /etc/updatedb.conf -
Locate the
PRUNEPATHSvariable. It contains a list of paths that should be excluded from indexing. -
Add the directories you want to exclude to the
PRUNEPATHSvariable. For example:1PRUNEPATHS="/tmp /var/spool /media /home/myuser/private"Replace the paths in the example with the directories you want to exclude.
-
Save the changes and exit the text editor.
These steps allow you to fine-tune which directories are indexed by updatedb.mlocate, helping you further control disk I/O and the scope of your mlocate database.
Remember to use these commands with caution, as they can impact the functionality of the mlocate service on your system.