Spotlight fix via Self Service

Valued Contributor

A few folks with 10.7 that were on-top-of upgraded from 10.6 are reporting spotlight isn't working; it offers no results.

Looking for ideas or warnings concerning offering a spotlight reset via Self Service. Has anyone had any experience with offering it to their users?

I am about to offer a policy that has the following Run Command:

sudo mdutil -E -i on /

At this point, I don't see the need to create a script.

Is there any pre or post steps I should be considering?


Legendary Contributor III

That looks fine from where I'm sitting. If it were me the only difference I might do is make the users reboot after the command, just to be fully sure the Indexing will start up. I've seen rare occasions where even deleting the index and reenabling indexing doesn't kick it off, but it shouldn't strictly be necessary. I may also be thinking pre Lion. I think its more stable now.

Contributor III

if you're running it via the "run command" field, you shouldn't need to preface with sudo. it's running as root already, no?

Honored Contributor

Correct, Nate. The Casper admin account runs anything in that run command field (as well as scripts, I believe) with sudo rights.

Legendary Contributor III

Yes, it does run as root, and therefore no need for the 'sudo' but in truth, having it in there does no harm that I've ever seen. It ignores the sudo since it doesn't need to escalate its own privileges. In other words, it works just the same either way as far as I can tell. If someone has proof otherwise, please correct me.

Contributor III

while that's true, mike, i always cringe when seeing mac admins throw around sudo when it's not needed. just trying to reinforce good habits (of knowing what you're doing).

Legendary Contributor III

Oh, I agree Nate. You're absolutely right. If its not needed, it shouldn't be there. I was just trying to point out that in this case, it isn't all that different than opening a sudo shell in Terminal and then doing a sudo command. Its unnecessary, but not dangerous or anything. At least as far as I know. Probably best to just leave it out though as you state.

Valued Contributor II

Does this ```
mdutil -E -i on /
``` accomplish the same thing as:


# disable indexing of the root volume

mdutil -i off

echo "Indexing has been disabled"

# delete the Spotlight index

rm -R /.Spotlight-v100

echo "Index file has been deleted"

# reset the data cache for your Mac’s hard drive:

mdutil -E /

echo "Data cache has been deleted"

#re-indexing your hard drive

mdutil -i on /

echo "Re-indexing your hard drive"

/usr/sbin/jamf displayMessage -message "The Spotlight index has been reset for your computer. It may take a few hours to completely reindex your hard drive"

exit 0

in one line, and is the indexing stop unneccesary?

New Contributor
rm -R /.Spotlight-v100

Is not necessary because because the -E flag will delete and recreate the index.

I don't believe it is necessary to stop spotlight before issuing the -E flag, but in some cases it is beneficial to stop spotlight from indexing to do work then re-enable it.

mdutil -E -i on /

That will delete and re-create the index on your root partition;

mdutil -E -a -i on

will delete and re-create the index on all drives, excluding network drives.


New Contributor

Just had this problem and i fixed this with the following two commands.......

sudo rm -i .metadata_never_index

sudo mdutil -E -a -i on