I am having trouble to make Spotlight permanently work for network drives on both Sierra and High Sierra.
I have a NAS (WD MyCloud, running some proprietary linux, kinda busybox) on my local network. I connect to it using AFP protocol. The given shares mounted somewhere in my home folder ~/path-to-share
. I can enable Spotlight search by manually starting indexing the volume.
sudo mkdir /private/var/db/Spotlight-V100/Volumes/
mdutil -i on ~/path_to_mount
The first line is needed since Sierra, without that, you will always get Indexing disabled.
in the terminal (this is a fix a lot of people looking for). This will start mdworker, and the indexing starts. After it finishes Spotlight works as it supposed, temporarily. BUT once you unmount the share and mount it (the same way) again Spotlight stops finding anything within it.
During indexing a local database is built under /private/var/db/Spotlight-V100/Volumes/afp%3A
. If you take look at the content of this folder, one can find further subfolders name according to user@server_name nomenclature. This would suggest, that it would recognize the server. Manually rebuilding the index with mdutil -i on E ~/path_to_mount
"restarts" proper Spotlight functioning, but it can take hours with a considerably large network share, which is unmounted automatically with one single WiFi network change (I am using a portable computer).
So the question would be how can you make Spotlight find/read/use the already existing - not corrupted - index database.
I have tried different mounting methods, same result: Finder, command line (mount -w -o nosuid -o nodev -t afp afp://server_name/share_name ~/path_to_mount
). I have also tried to mount to the default /Volumes/
path, the same result. I can not reload to associated deamon /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
since it is protected by SIP. I have tried everything with SMB sharing also.
Interestingly this problem seems to annoy only a handful of people, I could only find one similar question (How to force spotlight to reimport index), but dozens and dozens of "How to rebuild Spotlight index". Am I missing something obvious?