Detaching a datastore or storage device from multiple ESXi 5.0 hosts

Purpose

This article provides information on detaching a datastore or storage device from multiple ESXi 5.0 hosts.
 
Note: The documented method using the vSphere Client is limited to detaching the device on a per-host basis. Alternative methods may be required if a storage device is presented to multiple hosts.

Resolution

Note: For instructions on how to unpresent a LUN from an ESXi 5.0 host, see   Unpresenting a LUN in ESXi 5.x (2004605).


Using the vSphere Client
 
To detach a storage device using the vSphere client, see Detach Storage Devices in the vSphere 5 Documentation Center. 
 
Caution: You should successfully unmount the datastore using the documented method prior to completing the steps described below. For more instructions, see Unmount VMFS or NFS Datastores in the vSphere 5 Documentation Center.
 
To detach a storage device using the vSphere client:
  1. Select on the desired host.
  2. Click the Configuration tab.
  3. Click Storage Adapters.
  4. Click on the applicable host bus adapter.
  5. Right-click on the applicable device.
  6. Click Detach.
  7. Repeat Steps 2-7 for each host that can access the storage device.

Using esxcli

To detach a storage device using the esxcli command, see Detaching Devices and Removing a LUN in the vSphere 5 Documentation Center.

Using the PowerCLI

To detach a storage device using PowerCLI:
  1. Review the VMware Contributed Sample Code disclaimer, and deploy the community-supported PowerCLI script available atAutomating Datastore/Storage Device Detachment in vSphere 5

  2. Ensure that you have already unmounted the desired datastore. For more information, see Unmount VMFS or NFS Datastoresin the vSphere 5 Documentation Center. 

  3. List all datastores and their attached hosts by running the command:

    Get-Datastore | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT –AutoSize

    You see an output similar to:

    Datastore                VMHost              Lun                                                                        Mounted State  
    ---------                ------              ---                                                                        ------- -----  
    IX2ISCSI01               esx01.vmw.local     naa.5000144f52145699                                                         False Attached
    IX2ISCSI01               esx02.vmw.local     naa.5000144f52145699                                                         False Attached
    IX2ISCSI01               esx03.vmw.local     naa.5000144f52145699                                                         False Attached
    LocalDatastore           esx01.vmw.local     mpx.vmhba1:C0:T0:L0                                                           True Attached
    LocalDatastore           esx02.vmw.local     mpx.vmhba1:C0:T0:L0                                                           True Attached
    esx04-Internal-150GB     esx04.vmw.local
         t10.ATA_____GB0160EAPRR_____________________________WCAT25563003________      True Attached
    esx04-Internal-500GB     esx04.vmw.local     t10.ATA_____WDC_WD5000AAKS2D00V1A0________________________WD2DWMAWF0069467    True Attached
    esx03-Internal-150GB     esx03.vmw.local     t10.ATA_____GB0160EAPRR_____________________________WCAT25704089________      True Attached
    esx03-Internal-500GB     esx03.vmw.local     t10.ATA_____WDC_WD5000AAKS2D00YGA0________________________WD2DWCAS85034601    True Attached

  4. Select the appropriate Datastore and record the name beneath the Datastore column, and confirm that the Mountedcolumn contains the value False for all hosts. 

  5. Detach the devices from all hosts using the command:

    Get-Datastore datastore name| Detach-Datastore

    Where datastore name is the name of the Datastore recorded in Step 3.

    You see an output similar to:

    Detaching LUN naa.5000144f52145699 from host esx01.vmw.local...
    Detaching LUN naa.5000144f52145699 from host esx02.vmw.local...
    Detaching LUN naa.5000144f52145699 from host esx03.vmw.local...

Using the vSphere SDK for Perl

To detach a storage device using Perl, do the following:
  1. Review VMware Contributed Sample Code disclaimer

  2. Deploy the community-supported Perl script available in the VMware vSphere Blog, Automating Datastore/Storage Device Detachment in vSphere 5.   

    Caution: Before proceeding, ensure you have already unmounted the desired datastore.  For more information, see Unmount VMFS or NFS Datastores in the vSphere 5 Documentation Center.

  3. List all datastores and their attached hosts by running this command:

    ./lunManagement.pl --server vcenter ip --username user --operation list

    Where vcenter ip is the IP address of the vCenter server managing your hosts and user is a user with administrative privileges.
       
  4. You will be prompted for a password for the user account used in Step 2. If the correct password is entered, the script generates an output similar to:

    Datastore: esx01-local-storage-1 LUN: mpx.vmhba1:C0:T0:L0
            esx01.vmw.local  MOUNTED   ATTACHED
    Datastore: esx02-local-storage-1 LUN: mpx.vmhba1:C0:T0:L0
            esx02.vmw.local  MOUNTED   ATTACHED
    Datastore: iSCSI-1 LUN: naa.600144f0a33bc20000004e9772510001
            esx01.vmw.local  UNMOUNTED   ATTACHED
            esx02.vmw.local  UNMOUNTED   ATTACHED
    Datastore: iSCSI-2 LUN: naa.600144f0a33bc20000004e9772ee0002
            esx01.vmw.local  MOUNTED   ATTACHED
            esx02.vmw.local  MOUNTED   ATTACHED
    Datastore: iSCSI-3 LUN: naa.600144f0a33bc20000004e9773560003
            esx01.vmw.local  MOUNTED   ATTACHED
            esx02.vmw.local  MOUNTED   ATTACHED
    Datastore: iSCSI-4 LUN: naa.600144f0a33bc20000004e9773560004
            esx01.vmw.local  MOUNTED   ATTACHED
            esx02.vmw.local  MOUNTED   ATTACHED
    Datastore: iSCSI-5 LUN: naa.600144f0a33bc20000004e9773570005
            esx01.vmw.local  MOUNTED   ATTACHED
            esx02.vmw.local  MOUNTED   ATTACHED


  5. Confirm that the datastore that you want to detach has been unmounted by observing the UNMOUNTED keyword beneating the applicable datastore name and naa value. 

  6. Detach the device across multiple hosts by running this command:

    ./lunManagement.pl --server vcenter ip> --username user --operation detach --datastore datastore

    Where vcenter ip is the IP address for the vCenter server, user is the user with administrative privileges, anddatastore is the name of the datastore identified in Step 4.  

  7. You will be prompted for a password and confirmation that you wish to do the operation. After providing the correct password and acknowledging the warning, the tool generates an output similar to:

    Detaching LUN "0200000000600144f0a33bc20000004e9772510001434f4d535441" from Host "esx01.vmw.local" ...
            Successfully detached LUN!
    Detaching LUN "0200000000600144f0a33bc20000004e9772510001434f4d535441" from Host "esx02.vmw.local" ...
            Successfully detached LUN!

Based on VMware KB 2011506
  • 0 Los Usuarios han Encontrado Esto Útil
¿Fue útil la respuesta?

Artículos Relacionados

Hardware and firmware requirements for 64-bit guest operating systems

PurposeThis article explains the host machine hardware and firmware requirements for installing...

Logging in to the vCenter Server 5.0 Web Client fails with the error: unable to connect to vCenter Inventory Service

DetailsAfter upgrading from vCenter Server 4.1 to 5.0, you experience these symptoms:Cannot log...

Multiple network entries in vCenter Server 5.0.x after migrating virtual machines from a virtual switch to a virtual distributed switch

SymptomsAfter migrating virtual machines from a virtual switch to a virtual Distributed...

Minimum requirements for the VMware vCenter Server 5.x Appliance

PurposeIf you are using the VMware vCenter Server Appliance, beginning with vSphere 5.0 you can...