You're wrong. The first command fails.
The second command is not required.
(BTW, to add /Volumes, you may want to use your Finder and add it to your Favorites on your left before following my instructions to be able to find it easier when using the settings. The settings does not show hidden folders and you'll have a harder time navigating or, I'm still getting used to Mac. Just be aware, if you don't see it following my instructions, you can add it to your Favorites, then exclude it by selecting it from there)
FINAL EDIT: I have used Linux 20+ years. How many Mac users do you think want to have to use the terminal bud? It's different for us that use it daily ... Many people don't want to be executing system/root commands they don't understand. Do you even understand the commands or are you just copy/pasting? I've been in *nix environments for my whole life. I can answer for you but, I won't.
They can simply open the spotlight settings and add /Volumes through the GUI like I said above.
Then they can delete the spotlight folder. It is how I did it before posting.
I just tried your way and, the first command gets permission denied even as root on newest mac.
Your need to reply last has wasted multiple peoples' time or, will.
OF COURSE, it looks like the person above me "Ninja Edited" so here is their original reply:
(BUT AGAIN, Use the Settings -> Spotlight -> Add /Volumes to exclusion instead [pick "Search Privacy" at the very bottom-right as of current Mac version] , not what is below, I just won't be made to look a fool by a ninja edit)
Last person's actual reply:
"""
Try creating the following file at the root of the volumes:
.metadata_never_index
It doesn't need any content. You can just do:
touch .metadata_never_index
using the Terminal. It may be possible using the Finder too, but it's more tricky.
If you already have a spotlight index that you want to remove, you can do the following:
sudo mdutil -X /Volumes/
You will have to use this command. You won't be able to delete the Spotlight index on the volume otherwise.
"""