vSphere Howto: Remove a LUN from an ESXi server

In most cases you will add VMFS volumes (LUNs) to your vSphere environment, because most of the time your environment will grow. Adding a LUN is very simple: Just configure the masking correctly on your SAN, carry out a rescan on your ESXi server (or the entire cluster) and voilá you have your LUN/volume available.

But what about removing a LUN from your environment. This is a bit more tricky, you have to think about:

1. No virtual machines are using the LUN you want to remove. The LUN should not be used as a RDM;

2. The LUN should not be a part of a datastorecluster and storage DRS should not be active on the LUN;

3. Storage IO Control should be disabled for the LUN;

4. The LUNs should not be used as a HA heartbeat datastore;

5. And the LUN should not be used as persistent scratch partition.

On top of that, you cannot just remove the LUN, even when it’s not used anymore by virtual machines. It’s very important to first unmount the LUN and then detach the LUN from your ESXi server.

Luckily VMware described a clear procedure in the following two KB articles:

1. Removing a LUN containing a datastore from VMware ESXi/ESX 4.x – KB 1029786

2. Unpresenting a LUN in ESXi 5: KB 2004605

It’s very important that you follow this procedure to prevent an All Paths Down (APD) situation on your ESXi server. APD may result  in a non-responsive hostd deamon, especially on ESXi 4.

The exact steps are available in this VMware KB article which will be summarized below:

  1. Confirm the LUN is not used by any virtual machine;
  2. Unmount the LUN in the vSphere client;
  3. Detach the LUN from the ESXi host;
  4. Unmask the LUN on your SAN.

To definite remove the LUN from your ESXi server you should remove the LUN from the detached LUN list as well, this requires three additional step:

  1. Connect to ESXi shell (through the DCUI or SSH) and enter the following command:
    # esxcli storage core device detached list
  2. Remove the detached volumes from this list:
    # esxcli storage core device detached remove -d NAA_ID
  3. Run a rescan on your HBA

After following this procedure something strange happened: although the LUN was umasked on the SAN, the removed LUN re-appeared.

What was the case? In this case the iSCSI solution (in this case Dell Equallogic) creates a seperate iSCSI target for each iSCSI volume. Despite of unmasking the LUN from the ESXi host, the iSCSI target for this volume was still accessible, which is something I wouldn’t expect. Because the ESXi host still has access to the target, the volume is also still usuable.

After removing the relevant iSCSI target from the static discovery tab in the software iSCSI properties tab, things were solved and worked as expected. Another solution is to reboot the host, this will also remove the not accessible iSCSI targets.

Important note: You can compare the detach option in ESXi 5 with a “server side masking” option. Removing a LUN from ESXi 4 involves some server side LUN masking, because there’s no detach option available. Removing LUNs from the detached device list on ESXi 5, is actually removing the “server side mask”. If you want to reconnect an earlier removed LUN to an ESXi server, the LUN shouldn’t be in the detached device list because the ESXi server will never see your represented LUN!

补充:

unmount步骤:

1. check LUN proper path

2. unmount LUN

3. detach LUN

 

你可能感兴趣的:(LUN)