Why does it take so much time to initialize mlocate database?

8,206

Solution 1

Searching Google for this issue, I found this gist which states the following:

[...] add /mnt to PRUNEPATHS in /etc/updatedb.conf in order to avoid indexing Windows files.

This is related to this previous answer:

[...] think the reason the mlocate installation took so long while stuck at 60% was because with was also indexing Windows files.

When I followed that gist instructions, it worked perfectly for me.

Solution 2

I installed ubuntu lts 20 on wsl2 on Windows 10 via Microsoft Store. It didn't came with locate installed, so I installed it. While installing, it got stuck for a long time at 60% when updating its database for the first time. Thought it went into some problem and Google it (and found this thread).

Turns out it eventually finished installing after like 15 min. When I used the command for the first time, I got a surprise: it actually parsed all my hard drive into its database, including all Windows stuff, even things I can't access normally through Windows.

So I think the reason the mlocate installation took so long while stuck at 60% was because with was also indexing Windows files.

Well, if you waited a whole night, then it may be a real problem with the installation. I would suggest to install another distro on your wsl or, at least, don't install locate on it.

Share:
8,206
Aditya Patnaik
Author by

Aditya Patnaik

Updated on September 18, 2022

Comments

  • Aditya Patnaik
    Aditya Patnaik almost 2 years

    While I was trying to install xubuntu-desktop on wsl2(Ubuntu 20.04) on windows 10.

    It got stuck at

    Initializing mlocate database; this may take some time...

    after waiting for a long time(left it for a whole night, as I heard this process takes a lot of time as it parses through every path present on the system)

    I closed the process and ran:

    sudo dpkg --configure -a

    again it's stuck at the same point.

    My question is:

    • How to resolve it?
    • Why does it take so much time?

    Any help will be appreciated.

    Thanks in advance!

  • Aditya Patnaik
    Aditya Patnaik about 4 years
    thanks for the answer @wsl2user. Well actually mlocate relies on a database that is reindexed daily by a cronjob. WSL doesn't handle cron. So, one could try running sudo updatedb.mlocate. It still takes a while to do the job but populates the db at /var/lib/mlocate/mlocate.db. Looking forward to wsl2 updates that might fix this.
  • augusto
    augusto over 3 years
    Linux gives you a wider control on what's happening. "Don't use" is a very remote option
  • NotTheDr01ds
    NotTheDr01ds almost 3 years
    Agreed that this is almost certainly the issue, and a good solution. Thanks for posting it here. IMHO, this should be the accepted answer if the OP ever gets a chance to try it out.
  • PranshuKhandal
    PranshuKhandal over 2 years
    This worked for me too.