mlocate is now 60 Gb - is it really necessary? [SOLVED]

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Micromet
Level 2
Level 2
Posts: 62
Joined: Tue Jan 08, 2019 10:27 am

mlocate is now 60 Gb - is it really necessary? [SOLVED]

Post by Micromet »

My Linux Mint 20.3 OS SSD is now just 10 Gb short of it's 120 Gb capacity. Of that var is 80 Gb and the largest part of lib in var that is mlocate at 60 Gb. From other threads I see that this is a database of files used in the locate function of Nemo. I rarely use either the find or locate functions as my /home is on a separate disk and even there I rarely need to do a search. Do I need to maintain all this (to my mind) wasted space in mlocate? If not - how do I disable or get rid of it it? Other threads have offered sudo apt-get purge mlocate - I guess to clean it up; and sudo apt-get remove mlocate to get rid of it.

Are the consequences of removing mlocate - just slow subsequent file searches or are there some hidden "gotchas" lurking?

I've just looked in mlocate and as well as mlocate.db - there are a huge number of mlocate.db.xxxxx files - which go right back to 14 March 2021 and they are each around 400 Mb. Is this the problem? - I've been storing old versions of the mlocate database. If so will the purge option be the most appropriate solution? And is there a command that says "only save latest mlocate.db file"
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
ajgreeny
Level 7
Level 7
Posts: 1656
Joined: Mon Nov 19, 2007 3:27 pm

Re: mlocate is now 60 Gb - is it really necessary?

Post by ajgreeny »

Something is most definitely wrong if your /var/lib/mlocate folder is that size; there is no way the file database should be that large. However I would also ask why you bother to retain the older database files; what purpose do they serve, or does that happen with no action on your part?

The single file in my mlocate folder is only 14.3 MB so I would need several thousand of those to make up the 60 GB size you mention.

I don't think mlocate is needed for any other activities than using the locate command so if I'm correct about that you could purge mlocate which should remove that /var/lib/mlocate folder and then simply use the find command in its place.
Micromet
Level 2
Level 2
Posts: 62
Joined: Tue Jan 08, 2019 10:27 am

Re: mlocate is now 60 Gb - is it really necessary?

Post by Micromet »

Thanks ajgreeny - yes I thought it a bit strange for versions of mlocate.db to be retained over the past year on what seems to be a random basis - sometimes each day - then again 4 or 5 days, then a week. I have not knowingly done anything for this to happen - my investigation of disk usage threw up mlocate - which until then I was completely unaware off. I have 156 versions of the mlocate.db.xxxxxx files (an example is mlocate.db.ZzNmY5) each of which range from 11 Mb right up to 640 Mb. I will purge them - but not at this stage remove mlocate - as I'd like to find out what is going on. But thanks for assuring me that soemthing is wrong.
t42
Level 11
Level 11
Posts: 3734
Joined: Mon Jan 20, 2014 6:48 pm

Re: mlocate is now 60 Gb - is it really necessary?

Post by t42 »

check your /etc/updatedb.conf

Code: Select all

man 5 updatedb.conf
-=t42=-
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: mlocate is now 60 Gb - is it really necessary?

Post by rene »

updatedb creates the mlocate.db.xxxx file as a temporary file while working and only when it finishes successfully moves it to mlocate.db itself. This would be to say that in poster's case updatedb isn't finishing; is crashing somewhere around the point of it hitting that 400MB point each time.

The locate database is used only by the locate command line tool; see viewtopic.php?p=2114541#p2114541 and/or the next post by Termy in that thread. I.e., much advised to just purge the thing; note that you will in your case and after purging want sudo rm /var/lib/mlocate/* to delete all.

There's too many possible causes for this to usefully diagnose from afar why it crashes; it might be mlocate itself but probably is something it touches on your system. As such, yes, PRUNEPATHS in the configuration can be useful if you'd have an idea what and how -- but just don't bother diagnosing: the thing crashes and seeing as how it's by and large useless and detrimental anyway just get rid of it.
Micromet
Level 2
Level 2
Posts: 62
Joined: Tue Jan 08, 2019 10:27 am

Re: mlocate is now 60 Gb - is it really necessary?

Post by Micromet »

Thanks to rene and t42. The purge command seems to also get rid of mlocate.db as well as the individual temporary files. After reboot there is no mlocate folder in /var/lib anymore. Of course I don't know when the mlocate.db gets created. And the man 5 update.db.conf command says there is "No manual entry for updatedb.conf in section 5.

As I have never used the locate function - I aim to take rene's advice (which he has often given in other threads) of not bothering with mlocate at all.

I regard this thread as solved - and thank all those who have helped me.
Locked

Return to “Software & Applications”