Unix & Linux Asked by Pro Backup on February 5, 2021
This 4.20.3 Arch system its BTRFS formatted /
disk is without free space left. It turns out that mlocate is the cause:
# du -h --exclude=Volumes -- * 2>/dev/null | sort -hr | head -2
11G var
9.6G var/lib/mlocate
The question updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db' accepted answer suggests to prepend sudo
, though that doesn’t change a thing:
# sudo updatedb
updatedb: `/var/lib/mlocate/mlocate.db' is locked (probably by an earlier updatedb)
There seems to be a temporary file in /var/lib/mlocate that is eating up all disk space:
# ls -lh var/lib/mlocate/
-rw-r----- 1 root locate 1.1M Oct 21 00:00 mlocate.db
-rw------- 1 root root 9.6G Dec 30 19:46 mlocate.db.PRvfsw
Could the root cause be the .timer
update job that is hanging?
# systemctl status updatedb.timer
* updatedb.timer - Daily locate database update
Loaded: loaded (/usr/lib/systemd/system/updatedb.timer; static; vendor preset: disabled)
Active: active (running) since Mon 2019-10-21 16:05:10 CEST; 2 months 9 days ago
Trigger: n/a
Both restart
and stop
don’t remove the temporary large .db file and updatedb
still returns locked
.
There seems to be an updatedb
process still running:
# ps -ef | grep updatedb
root 3249 1 99 Oct22 ? 213573-14:47:11 /usr/bin/updatedb
I know I can kill this process. The root cause is most likely a faulty USB stick:
# ls /Volumes/RM_GUE__
ls: cannot access '/Volumes/RM_GUE__/'$'0120': Input/output error
ls: cannot access '/Volumes/RM_GUE__/)': Input/output error
Though the next time a USB stick becomes faulty, /
will fill up again.
The updatedb.conf
options don’t bring me any useful filter option:
How to resolve this issue neat and permanently, for example by limiting the duration that updatedb.timer
may run and/or skipping disks which suffer input/output errors, or limit the file size LimitFSIZE=
or even something better?
The documentation for mlocate
(see man mlocate
) leads to updatedb
, which in turn says
The
PRUNE_BIND_MOUNTS
,PRUNEFS
,PRUNENAMES
andPRUNEPATHS
variables, which are modified by some of the options, are documented in detail inupdatedb.conf
(5).
Reading the documentation for that (man updatedb.conf
) and looking at the file /etc/updatedb.conf
shows two possible options to satisfy your requirement:
PRUNEFS
A whitespace-separated list of file system types (as used in /etc/mtab) which should not be scanned byupdatedb
(8). The file system type matching is case-insensitive.
PRUNEPATHS
A whitespace-separated list of path names of directories which should not be scanned byupdatedb
(8). Each path name must be exactly in the form in which the directory would be reported bylocate
(1).
If your USB sticks and other removable media are always mounted under /Volumes
you could add that directory to your PRUNEPATHS
setting in /etc/updatedb.conf
. On my Debian system this would result in
PRUNEPATHS="/tmp /var/spool /media /var/lib/os-prober /Volumes"
Alternatively, if your USB sticks are always FAT or NTFS you could add those filesystem types to the set of exclusions specified by PRUNEFS
.
Answered by roaima on February 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP