May 10

Using Spotlight to index external volumes

2005 at 03.51 am posted by Veerle

We at Duoh! use our Xserve to store all work and were wondering why Apple didn’t create an option in the interface to index external volumes with Spotlight. Or maybe it isn’t obvious enough to me and I didn’t find it yet? If we perform a search, 99% of the time it will be on an external mounted volume. 

This buggered me and I called in some help of our Terminal guru (oh! he'll like that! :-D) Kenneth. And guess what! My volume is now indexed and Spotlight now searches within files and I'm able to use smart folders on external volumes too. Only requirement is that the volume needs to be mounted to perform a search.

So here is what you need to do in Terminal... Apple are you reading this? Please implement this in the GUI, I'm not a Unix person :-D

  • First you need to be root. This is done by using sudo su
  • Enter your Mac's password
  • Type mdutil -i on /Volumes/x (x is the name of your volume)
  • Then type mdutil -p on /Volumes/x (x is the name of your volume)

A few seconds later you'll notice that the magnifying glass will show that something is being indexed. And if you look you'll see the name of your volume and the amount of time it will take. Oh and another bonus : it works on Linux partitions over Samba and on Windows volumes too :-)


18served

gravatar

1

permalink this comment Julian Tue May 10, 2005 at 05.07 am

Your talking about the Apple GUI and the terminal - can’t anyone create an automator script? I’m sorry, I do not have a mac for myself, but I’ll remember your tip when I got one (I hope this won’t be that far away in the future...)


gravatar

2

permalink this comment Raven Tue May 10, 2005 at 05.10 am

I wish I had an XServe… :-(
But it’s good news anyhow.


gravatar

3

permalink this comment Geert Tue May 10, 2005 at 05.29 am

Even sweeter for those who are too lazy to type the whole thing: you can even drop the volume in the terminal window after the mdutil -i on (space) and terminal will automatically type /Volumes/yourvolume


gravatar

4

permalink this comment Bryan Peters Tue May 10, 2005 at 07.36 am

Bummer for me.  I get “unknown indexing state” when trying mdutil -i on my windows persistent mounted share.  I have full rights to everything on there, but I can’t get it to index it. 

You’re right: I have 99% of my data sitting on there.  It should be easier to add it.  Hopefully they add it to the GUI in 10.4.1


gravatar

5

permalink this comment iWantToKeepAnon Tue May 10, 2005 at 07.49 am

“magnifying class” should be glass.

Being a Linux user, could you give a quick 1 line blurb about what Spotlight is?


gravatar

6

permalink this comment Keith Fox Tue May 10, 2005 at 08.37 am

Spotlight is the new seach utility built into Mac OS 10.4. Spotlight indexes everything except the system folder allowing for super quick searches.


gravatar

7

permalink this comment Stefan Seiz Tue May 10, 2005 at 08.41 am

AFAIK, the drawback is, that you must run these commands everytime after you mounted the fileserver volumes which is at least after every reboot…


gravatar

8

permalink this comment Julian Tue May 10, 2005 at 08.57 am

Yeah, I’d say an automator script could be useful.
@Linuxuser: Spotlight is http://www.apple.com/macosx/features/spotlight/


gravatar

9

permalink this comment Veerle Tue May 10, 2005 at 09.20 am

@Stefan Seiz: I don’t know what you did but I just ran a quick test by rebooting my Mac and it still works. I didn’t have to re-index that particular volume nor did I have to run those commands again. So it still works after a reboot.

@iWantToKeepAnon: Spotlight searches inside files like text in PSD’s, PDF’s, Word files etc. It is built into the Mac OS X 10.4 system.


gravatar

10

permalink this comment Stefan Seiz Tue May 10, 2005 at 09.34 am

Verle, of course the index is still there after a reboot, but it is not being updated anymore with the contents of new files (added to the server) for instance. So to rephraze it, in order to keep the index alive, you’d have to run the commands after every unmounting of a volume. And that is the pain. I am quite sure we’ll soon see a “Also include” preference pane in Spotlight’s System Preferences anytime soon. Maybe in 10.4.1 already.

You can easily verify this:
mdutil -s /Volumes/x
will tell you the status of a volume.

So if you:
mdutil -i on /Volumes/x
and then
mdutil -s /Volumes/x#
you’ll see spotlight indexing turned on.

Now quickly unmount /Volumes/x and remount it again.
mdutil -s /Volumes/x
will now show you spotlight indexing to be off.


gravatar

11

permalink this comment Veerle Tue May 10, 2005 at 09.44 am

@Stefan: Ok now I understand. Bugger :-( But I’m sure this will be solved soon. Should have been there in first place since a lot of people work on external volumes. Maybe somebody can create an Automator script for it? I would, but have no clue how to do it.  I wonder what happens if you run Tiger Server on a Xserve for example. We haven’t received it yet so I can’t find out.


gravatar

12

permalink this comment iWantToKeepAnon Tue May 10, 2005 at 11.34 am

(disclaimer: I apologize if all that follows is completly obvious to you all.  But I dont know Automator and I also dont know if you know un*x’s scripting languages.)

Since OSX is un?x based, it includes the standard un?x scripting languages (e.g. bash).  So cut and paste this into a file called “mount_x.bash” (or something memorable), and make it executable.

-------------------------begin
#!/bin/bash

sudo su
mdutil -i /Volumes/x
mdutil -p /Volumes/x
-------------------------end

Now run the script (maybe replace “/bin/bash” w/ bash’s location on OSX).  Since I assume it will prompt for a password, you need to tell your Mac to run this script in a terminal window so you can see and respond to the prompt.  It is possible to bypass passwords using public+private keys, but that is way too much detail for now.

If the extension “.bash” isnt associated with the bash interpreter, you may need to do some “Mac-ish” stuff to have the bash interpreter run this.  Very similar to setting the html extension to open your browser.

HTH


gravatar

13

permalink this comment Vincent Grouls Tue May 10, 2005 at 03.45 pm

Hmmm I recall that the first time Spotlight was indexing it was also indexing my external hard drive. I am sure that is because I had added it to the Privacy tab and then removed it again. You may want to try that with network drives etc.

I don’t have an XServe (unfortunately) but wouldn’t it be possible to run Spotlight indexing from _that_ machine?

ps, Don’t just foolishly try to mess with the Privacy tab; I just added my boot volume to it and removed it and now it’ll be indexing for the next half hour… :-/


gravatar

14

permalink this comment John Athayde Wed May 11, 2005 at 09.12 am

Thanks for the tip. Indexing the resource directories that dont’ change that often (3d/vfx) is great. Helps when I’m looking for that one texture file i’ve had for 2 years of an obscure brick pattern :)


gravatar

15

permalink this comment noah Wed May 11, 2005 at 10.04 am

And if you don’t like Terminal commands, you can download Highlight, fire it up and drop your volumes on that. Will try to find some time to automate that, once the source becomes available.  You can download Highlight (which is free) at this location: http://homepage.mac.com/superpixel/highlight/


gravatar

16

permalink this comment anne Fri May 13, 2005 at 08.16 am

sounds kind of interesting — but anyone trying to do the opposite and get rid of spotlight’s connection to external volumes like me..? i do have a problem each time when trying to release my firewire-backup-drive.. and since tiger i am not able to use my bluetooth headset anymore which i finally had configured after some time in panther, grmpf.


gravatar

17

permalink this comment Vincent Grouls Fri May 13, 2005 at 01.42 pm

anne, you should be able to add your external drive to the Privacy tab.

Go to Spotlight preferences. Choose the Privacy tab. Hit the + at the bottom and choose your drive, or simply drag and drop it in there.


gravatar

18

permalink this comment Tim Mason Mon Dec 5, 2005 at 12.49 am

This is great info!  However I have an interesting observation… If you search an XServe RAID with samba shares in 10.4.3 from a windows XP professional computer it is about 100 percent slower than searching a windows server from the XP client.  What gives?



Commenting is not available in this weblog entry.

Flickrness

buy something from my Amazon wishlist