I stumbled upon this vSphere blog post that has the procedure to remove a datastore the right way: Best Practice: How to correctly remove a LUN from an ESX host
UPDATE: For ESXi 5.0, I found it better to follow the KB mentioned in that blog post:
Unpresenting a LUN in ESXi 5.x
For ESXi 5.0, here's how I do a slightly modified vesion of the procedure listed in the post above with more information on items such as HA:
- Make sure all VMs are evacuated from the datastore/LUN.
- Using Datastore Browser, make sure there aren't any left-over directories or files. If there are, delete them (make sure they can safely deleted first, of course). Exception: the HA directory - you'll remove that a different way later. Also note that you won't be able to delete a file if it's in use.
- Make sure all vSphere features are disabled for the datastore (i.e. SIOC, Storage DRS)
- HA Datastore Heartbeating: There may be some cases where HA has chosen the datastore you're trying to remove. In this case, edit cluster settings and change Datastore Heartbeating to "select only from my preferred datastores", then select at least three datastores other than the one you're trying to remove. I highly recommend changing this setting back to "Select any of the cluster datastores" after you're finished removing this one.
- Next, for each host, go to Configuration\Storage\Datastores View, right-lick on the datastore and choose "unmount":
- The "Unmount Datastore Wizard" appears. Make sure all hosts are selected.
- Click next. Hopefully the next step will look like this:
- Click "Next" then "Finish". After a minute the datastore will be grayed-out and italicized.
- Then go to Configuration\Storage\Devices View, right-lick on the datastore and choose "detach"
- You get a pop-up dialog window similar to the one show above. Choose "OK. The device will be grayed-out and italicized after a few seconds.
- Go in to your SAN and remove LUN masking/unpresent the LUNs to the ESXi hosts.
- Finally, right-click on your cluster and choose "Rescan for Datastores". You may get a StorageConnectivityAlarm alert for every host in your cluster unless you disable this alert first.
I like to go into every host and check the storage adapter for the LUN just to make sure but I haven't found a problem with this procedure yet.