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!

  • 1
    Not normal. Should not take more than a few seconds on a slow HDD, a fraction of a second on an SSD. Of course, this is on Windows 10, so something specific may be going on. You may want to add in your title that this is on Windows 10. – vanadium Jun 18 at 10:19
  • okay, Thanks for the suggestion @vanadium – Aditya Patnaik Jun 18 at 10:44
  • The updatedb command (which is what's happening here) has to traverse the entire filesystem for the name of each file. If wsl2/Windows10 has some strange idea of "the entire filesystem", updatedb could get confused. Read man updatedb, you may be able to use options to control what's scanned. Run sudo updatedb .... manually, once you figure it out. Once the initial creation is done updates should be quicker. – waltinator Jun 18 at 18:22
  • Thanks @waltinator, I would try that. – Aditya Patnaik Jun 19 at 5:45
  • @vanadium a 2Tb disk that is near full can take 6 days. – Rinzwind Jun 23 at 14:45

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.

| improve this answer | |
  • 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. – Aditya Patnaik Jun 23 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.