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:
1
sudo killall updatedb.mlocate
This command will stop any currently running
updatedb.mlocate
processes. -
Prevent Automatic Execution:
Disable the automatic execution of the
updatedb.mlocate
service by removing its execute permission:1
sudo chmod -x /etc/cron.daily/mlocate
This step ensures that the
updatedb.mlocate
script won’t run automatically. -
Delete the Existing Database:
You can also delete the existing mlocate database to free up disk space:
1
sudo rm /var/lib/mlocate/mlocate.db
Deleting 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
mlocate
script in the daily cron directory:1
sudo chmod +x /etc/cron.daily/mlocate
This 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.,
nano
orvi
):1
sudo nano /etc/updatedb.conf
-
Locate the
PRUNEPATHS
variable. It contains a list of paths that should be excluded from indexing. -
Add the directories you want to exclude to the
PRUNEPATHS
variable. For example:1
PRUNEPATHS="/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.