Many things can cause Spotlight to misbehave. Here are two of them, and their solutions.
NOTE: The standard first step is to add the problematic drive to the Privacy tab in System Preferences… > Spotlight > Privacy, then remove it. This post discusses cases where that fails.
In our case, Spotlight refused to index external drives that were newly formatted and then cloned with SuperDuper. The clonings were performed with a full "Erase _____, then copy files from ____" on 4 drives. This does not copy the Spotlight database, because it is rarely meaningful on the destination drive. Instead, macOS creates a new folder named “.Spotlight-V100” whenever it mounts a drive for the first time.
Notice the dot prepended to the filename. That means the file is hidden in Finder. To make it visible, type Shift-CMD-period at any time in Finder.
SOLUTION
By comparing files, folders and plist contents of a problem drive with those of a working drive, we discovered that two things needed to happen.
Step 1. In the drive root, delete this file: .metadata_never_index_unless_rootfs
Step 2. In the folder /.Spotlight-V100, replace a line in this file: VolumeConfiguration.plist.
On the problem drives, the plist contains lines something like this, which tells Spotlight not to index this drive at all:
<key>Exclusions</key>
<array>
<string>/</string>
</array>
We replaced these lines with this:
<key>Exclusions</key>
<array/>
<key>Options</key>
- Performing Step 1 without Step 2 has no effect.
- Performing Step 2 without Step 1 has no effect.
To check for success, launch Terminal, and issue this command:
sudo mdutil -a -i on /
It will report which drives have Spotlight enabled and which do not.
APPLE SUPPORT FAILS
On the first phone call to Apple Support, a Senior Advisor told us, “Contact all the drive manufacturers. It is their fault.“ This is utter nonsense. At one point, she even told me to upgrade to Monterey, as a fix.
On the second phone call to Apple Support, a tech suggested that Spotlight is finding a mismatch between the name of the cloned volume and drive ID it is expecting to see. Also utter nonsense.
Dave Nivian at Shirt Pocket software was most patient and informative in helping me solve this, even though it had nothing to do with his SuperDuper.