(Automation) Proper way of unmounting multiple datastores from ESXi Host
Recently I was facing an issue while detaching vSphere datastores from ESXi hosts. I removed the luns from esxi hosts but the luns where still present on the hosts as detached luns. So question is how to properly remove datastores from ESXi hosts. You need to do following tasks inorder to properly unmount a datastore from ESxi host.
1.Set datastore under maintanance. Remove datastores from all esxi hosts
2.Remove datastore/lun naa. id from detached list
Lets go deep to understand each step
1. Remove datastores from all esxi hosts
- Make sure the datastore is not used by any virtual machine(VM)
- Put datastore to SDRS maintenance mode
- Unmount and detach the LUN
2. Remove datastore/lun naa. id from detached list
- Connect to ESXi shell (through the DCUI or SSH) and enter the following command:
# esxcli storage core device detached list - Remove the detached volumes from this list:
# esxcli storage core device detached remove -d NAA_ID - Rescan all esxi hosts
3. Last step is to Inform storage administrator to delete the LUN
I know this is a time consuming task if you have a big environment. Happy news is that I have automated most of the steps using vSphere powercli (thanks to my friend Joao Grade for helping me with this script which is automated the whole process of removing multiple datastores from your esxi hosts. Script is totally free to download)
Remember to share with your colleagues.
Click Here to Connect with Jobi via Instagram