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
1
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...)
2
I wish I had an XServe… :-(
But it’s good news anyhow.
3
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
4
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
5
“magnifying class” should be glass.
Being a Linux user, could you give a quick 1 line blurb about what Spotlight is?
6
Spotlight is the new seach utility built into Mac OS 10.4. Spotlight indexes everything except the system folder allowing for super quick searches.
7
AFAIK, the drawback is, that you must run these commands everytime after you mounted the fileserver volumes which is at least after every reboot…
8
Yeah, I’d say an automator script could be useful.
@Linuxuser: Spotlight is http://www.apple.com/macosx/features/spotlight/
9
@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.
10
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.
11
@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.
12
(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
13
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… :-/
14
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 :)
15
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/
16
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.
17
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.
18
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?