In Ubuntu Server, mlocate (or its modern equivalent, plocate) is a powerful utility designed to rapidly index the entire file system into a database, allowing administrators to find files instantly using the locate command. This database is automatically refreshed by a daily systemd background unit known as the mlocate.timer (or plocate-updatedb.timer on newer builds). While convenient for quick searches, allowing a background daemon to silently execute a heavy, disk-intensive recursive scan across the entire file tree introduces a severe operational liability on mission-critical production servers, high-IOPS database clusters, or massive network-attached storage (NAS) deployments. This automated indexer consumes massive amounts of disk I/O, thrashes the page cache, and can cause devastating latency spikes during peak production hours.
This guide explains how to completely disable the mlocate.timer in Ubuntu Server, enforcing an absolute block on automated file system indexing and ensuring the server’s disk I/O remains entirely dedicated to production workloads.
Stop and Mask the mlocate Timer
Because the indexing routine is hardcoded into Ubuntu’s default systemd architecture via the mlocate/plocate packages, simply stopping it temporarily is insufficient, as OS reboots will regenerate it. To enforce a strict, immutable block, we must explicitly mask the systemd timer.
- Log into your Ubuntu Server via SSH using an account with
sudoprivileges. - Stop the timer to halt any currently scheduled execution:
sudo systemctl stop mlocate.timer - Stop the associated service unit that the timer invokes, aborting any active background disk scans:
sudo systemctl stop mlocate.service - Mask both the timer and the index service units. This symlinks them to
/dev/null, creating a hard block against future activation by cron triggers, OS updates, or manual invocations:sudo systemctl mask mlocate.timer sudo systemctl mask mlocate.service - Reload the systemd daemon to instantly apply the new masked states:
sudo systemctl daemon-reload
Verify the Service Lockdown
By masking the timer, you guarantee that systemd will completely reject any attempt to invoke the updatedb disk scan, reserving 100% of the disk I/O for your applications.
To verify the lockdown is successful, attempt to start the timer manually:
sudo systemctl start mlocate.timer
Systemd will immediately return a fatal error stating that the unit is masked (e.g., Failed to start mlocate.timer: Unit mlocate.timer is masked). Furthermore, running systemctl status mlocate.timer will explicitly display loaded (/dev/null; masked). Administrators can still manually execute sudo updatedb if they explicitly require a search index update, but the automated, background I/O thrashing is now strictly prohibited. The server’s disk performance is now secure.