Prevent Spotlight from indexing external drive
You could have a script that runs at startup that employs the technique suggested in this post https://apple.stackexchange.com/a/91759/183505

When booting from DriveA (when you want to disable spotlight indexing for External DriveB) you could execute :

touch /Volumes/DriveB/.metadata_never_index


When booting from external DriveB and you want to re-enable spotlight perhaps you could have your startup script execute:

rm /Volumes/DriveB/.metadata_never_index


The linked post also lists other ways to programatically alter the spotlight exclusions.

Here are some ways to add a script that will launch at login : https://stackoverflow.com/questions/6442364/running-script-upon-login-mac

Good luck!



Edit : Method using bash scripts and plist files



First create a startup script. I chose to create one at ~/script.sh

Make sure it's executable chmod +x ~/script.sh

Script for OS that wants to hide a drive from spotlight

#!/bin/bash
flagLocation="/Volumes/DriveToHide"
flagRemoved=".ney_the_index"  # a new name

# if flag exists rename it.
if [ -a "$flagLocation/.metadata_never_index" ]; then 
    mv "$flagLocation/.metadata_never_index" "$flagLocation/$flagRemoved";
fi


Script on the OS that wants to index the drive

#!/bin/bash
flagLocation="/Volumes/DriveToHide"
flagRemoved=".ney_the_index"

if [ -a "$flagLocation/$flagRemoved" ]; then
    mv "$flagLocation/$flagRemoved" "$flagLocation/.metadata_never_index"
fi

if [ ! -a "$flagLocation/$flagRemoved" ] || [ ! -a "$flagLocation/.metadata_never_index" ] ; then
    touch "$flagLocation/.metadata_never_index"
fi


Create a plist file ~/Library/LaunchAgents/com.user.loginscript.plist

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
   &lt;key&gt;Label&lt;/key&gt;
   &lt;string&gt;com.user.loginscript&lt;/string&gt;
   &lt;key&gt;Program&lt;/key&gt;
   &lt;string&gt;/Users/yourusername/script.sh&lt;/string&gt;
   &lt;key&gt;RunAtLoad&lt;/key&gt;
   &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Test it by loading and unloading it:

launchctl load ~/Library/LaunchAgents/com.user.loginscript.plist