VMware Cloud Community
EnricoJaeschke
Contributor
Contributor

problem with unmount and detach lun/datastore

Hi everybody,

we have a little script which detaches a lun/datastore from one or more hosts in a cluster. that works fine but we want to expand this now with the command 'esxcli storage core device detached remove' that the lun ID will also deleted from the host (to prevent a PDL).

i've tried to do this with the help of this documentation: VMware vSphere 6.5 Documentation Library

commands for detaching:

$hostesxcli.storage.core.device.set.Invoke(@{device='naa.60080e5000243010000005ff5b2123ab';state='off'})

-> device has now state off and isn't visible anymore in vcenter

$hostesxcli.storage.core.device.detached.list.invoke()

-> showing me the detached lun on host

$hostesxcli.storage.core.device.detached.remove.Invoke(@{device='naa.60080e5000243010000005ff5b2123ab'})

-> removes the lun ID from host

--> here is the problem! after this removing the lun is now visible again in vcenter after a HBA rescan. when i see the details for this lun with command:

$hostesxcli.storage.core.device.list.invoke(@{device='naa.60080e5000243010000005ff5b2123ab'})

the state is now 'on' again.

in this state i wouldn't delete the lun in our san environment because i think this will be causes a PDL.

could you help me pls or explain me the correct commands?

Thanks in advance!

0 Kudos
1 Reply
LucD
Leadership
Leadership

Shouldn't you unpresent the LUN from the SAN after storage.core.device.detached.remove?

And before doing a rescan of the HBA, otherwise the LUN will still be discovered by the rescan and be shown.

See also KB2004605


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos