Turn of spotlight and mds from scanning your external hdd

Quite often when having problem ejecting the external hard disk from my Mac OS X. I’m getting error saying that there the hard disk is being used.

So to check which process is using the volume with this command.

$sudo lsof | grep /Volumes/1TB\ Toshiba

Then I found out that a lot of the process was from mds and ms_store. These were from spotlight. So the next thing is to exclude this volume from spotlight, by adding it into the System Preferences > Spotlight > Privacy 

Then next, manually turn off from terminal.

$mdutil -i off /Volumes/1TB\ Toshiba