Thursday, September 29, 2011

Masking a LUN from ESX and ESXi using MASK_PATH plug-in

Refer http://kb.vmware.com/kb/1009449

1. See what plug-ins currently installed.
[root@esx1 ~]# esxcfg-mapth -G
MASK_PATH
NMP

The output indicates that there are, at a minimum, 2 plug-ins: the VMware Native Multipath Plug-in (NMP) and the MASK_PATH plug-in, which is used for masking LUNs. There may be other plug-ins if third party software (such as EMC PowerPath) is installed.

2. List all the claimrules currently on the ESX
[root@esx1 ~]# esxcli corestorage claimrule list
Rule Class Rule Class Type Plugin Matches
MP 0 runtime transport NMP transport=usb
MP 1 runtime transport NMP transport=sata
MP 2 runtime transport NMP transport=ide
MP 3 runtime transport NMP transport=block
MP 4 runtime transport NMP transport=unknown
MP 101 runtime vendor MASK_PATH vendor=DELL model=Universal Xport
MP 101 file vendor MASK_PATH vendor=DELL model=Universal Xport
MP 65535 runtime vendor NMP vendor=* model=*

There are 2 MASK_PATH entries: one for runtime class and th other for file class.
The runtime class is the rules currently running in the PSA. The file class is a reference to the rules defined in the /etc/vmware/esx.conf.

[root@esx1 vmware]# grep "PSA/MP/claimrule" /etc/vmware/esx.conf
/storage/PSA/MP/claimrule[0101]/match/model = "Universal Xport"
/storage/PSA/MP/claimrule[0101]/match/vendor = "DELL"
/storage/PSA/MP/claimrule[0101]/plugin = "MASK_PATH"
/storage/PSA/MP/claimrule[0101]/type = "vendor"

These are identical, but they could be different if you are in the process of modifying the /etc/vmware/esx.conf.

3.Add a rule to hide a LUN with the command:
# esxcli corestorage claimrule add --rule -t location -A hba_adapter -C Channel -T Target -L LUN -P MASK_PATH

Find the naa device of the datastore whith the command:
[root@esx1 vmware]# esxcfg-scsidevs --vmfs
mpx.vmhba0:C0:T0:L0:5 /dev/sda5 4e7361ce-9cb305f4-f136-000c29f15a51 0 Storage1
t10.F405E46494C45400259395867725D24567F444D253651786:1 /dev/sdd1 4e77768a-5e318913-6036-000c29f15a51 0 iSCSI_Shared

In this document, I will mask iSCSI_shared datastore. Check all of the paths that naa device has (vmhba33:C0:T0:L0):

[root@esx1 vmware]# esxcfg-mpath -L| grep F405E46494C45400259395867725D24567F444D253651786
vmhba33:C0:T0:L0 state:active t10.F405E46494C45400259395867725D24567F444D253651786 vmhba33 0 0 0 NMP active san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1
[root@esx1 vmware]#

iSCSI_Shared datastore has only 1 path to the device.

Add the rule with the command:
[root@esx1 vmware]# esxcli corestorage claimrule add --rule 192 -t location -A vmhba33 -C 0 -L 0 -P MASK_PATH

The claim rules are evaluated in numerical order starting from 0.
n Rules 0–100 are reserved for internal use by VMware.
n Rules 101–65435 are available for general use. Any third party multipathing plugins installed on your system use claim rules in this range.
n Rules 65436–65535 are reserved for internal use by VMware.


4.Verify that the rule has taken with the command:
[root@esx1 vmware]# esxcli corestorage claimrule list
Rule Class Rule Class Type Plugin Matches
MP 0 runtime transport NMP transport=usb
MP 1 runtime transport NMP transport=sata
MP 2 runtime transport NMP transport=ide
MP 3 runtime transport NMP transport=block
MP 4 runtime transport NMP transport=unknown
MP 101 runtime vendor MASK_PATH vendor=DELL model=Universal Xport
MP 101 file vendor MASK_PATH vendor=DELL model=Universal Xport
MP 192 file location MASK_PATH adapter=vmhba33 channel=0 target=* lun=0
MP 65535 runtime vendor NMP vendor=* model=*

See there is rule 192 for file class.

5.Reload claimerules with the command:
[root@esx1 vmware]# esxcli corestorage claimrule load

6.Re-examine claim rules and verify both the file and runtime class.
[root@esx1 vmware]# esxcli corestorage claimrule list
Rule Class Rule Class Type Plugin Matches
MP 0 runtime transport NMP transport=usb
MP 1 runtime transport NMP transport=sata
MP 2 runtime transport NMP transport=ide
MP 3 runtime transport NMP transport=block
MP 4 runtime transport NMP transport=unknown
MP 101 runtime vendor MASK_PATH vendor=DELL model=Universal Xport
MP 101 file vendor MASK_PATH vendor=DELL model=Universal Xport
MP 192 runtime location MASK_PATH adapter=vmhba33 channel=0 target=* lun=0
MP 192 file location MASK_PATH adapter=vmhba33 channel=0 target=* lun=0
MP 65535 runtime vendor NMP vendor=* model=*


[root@esx1 vmware]# esxcfg-mpath -L
vmhba32:C0:T0:L0 state:active mpx.vmhba32:C0:T0:L0 vmhba32 0 0 0 NMP active local ide.vmhba32 ide.0:0
vmhba0:C0:T0:L0 state:active mpx.vmhba0:C0:T0:L0 vmhba0 0 0 0 NMP active local pscsi.vmhba0 pscsi.0:0
vmhba33:C0:T0:L0 state:active t10.F405E46494C45400259395867725D24567F444D253651786 vmhba33 0 0 0 NMP active san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1
vmhba33:C0:T0:L1 state:active t10.F405E46494C45400A645A56644F6D23626A435D207248425 vmhba33 0 0 1 NMP active san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1

7.Unclaim all paths to a device then run the loaded claimrules on each of the paths to reclaim them.
[root@esx1 vmware]# esxcli corestorage claiming reclaim -d t10.F405E46494C45400259395867725D24567F444D253651786

8.Verify that the masked device is no longeer used by the ESX host.
[root@esx1 vmware]# esxcfg-scsidevs -m
mpx.vmhba0:C0:T0:L0:5 /dev/sda5 4e7361ce-9cb305f4-f136-000c29f15a51 0 Storage1
[2011-09-29 15:43:22 'VmFileSystem' warning] Skipping extent: t10.F405E46494C45400259395867725D24567F444D253651786:1. Not a known device: t10.F405E46494C45400259395867725D24567F444D253651786


[root@esx1 vmware]# esxcfg-mpath -L
vmhba32:C0:T0:L0 state:active mpx.vmhba32:C0:T0:L0 vmhba32 0 0 0 NMP active local ide.vmhba32 ide.0:0
vmhba0:C0:T0:L0 state:active mpx.vmhba0:C0:T0:L0 vmhba0 0 0 0 NMP active local pscsi.vmhba0 pscsi.0:0
vmhba33:C0:T0:L0 state:dead (no device) vmhba33 0 0 0 MASK_PATH dead san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1
vmhba33:C0:T0:L1 state:active t10.F405E46494C45400A645A56644F6D23626A435D207248425 vmhba33 0 0 1 NMP active san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1
[root@esx1 vmware]#

Unclaiming MASKED LUN

[root@esx1 vmware]# esxcfg-mpath -L
vmhba32:C0:T0:L0 state:active mpx.vmhba32:C0:T0:L0 vmhba32 0 0 0 NMP active local ide.vmhba32 ide.0:0
vmhba0:C0:T0:L0 state:active mpx.vmhba0:C0:T0:L0 vmhba0 0 0 0 NMP active local pscsi.vmhba0 pscsi.0:0
vmhba33:C0:T0:L0 state:dead (no device) vmhba33 0 0 0 MASK_PATH dead san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.openf iler:tsn.b6998f7991b4,t,1
vmhba33:C0:T0:L1 state:active t10.F405E46494C45400A645A56644F6D23626A435D207248425 vmhba33 0 0 1 NMP active san iqn.1998-01.com.vmware:esx1-0f77 0b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1


[root@esx1 vmware]# esxcli corestorage claimrule delete --rule 192


[root@esx1 vmware]# esxcli corestorage claimrule list
Rule Class Rule Class Type Plugin Matches
MP 0 runtime transport NMP transport=usb
MP 1 runtime transport NMP transport=sata
MP 2 runtime transport NMP transport=ide
MP 3 runtime transport NMP transport=block
MP 4 runtime transport NMP transport=unknown
MP 101 runtime vendor MASK_PATH vendor=DELL model=Universal Xport
MP 101 file vendor MASK_PATH vendor=DELL model=Universal Xport
MP 192 runtime location MASK_PATH adapter=vmhba33 channel=0 target=* lun=0
MP 65535 runtime vendor NMP vendor=* model=*


[root@esx1 vmware]# esxcli corestorage claimrule load


[root@esx1 vmware]# esxcli corestorage claimrule list
Rule Class Rule Class Type Plugin Matches
MP 0 runtime transport NMP transport=usb
MP 1 runtime transport NMP transport=sata
MP 2 runtime transport NMP transport=ide
MP 3 runtime transport NMP transport=block
MP 4 runtime transport NMP transport=unknown
MP 101 runtime vendor MASK_PATH vendor=DELL model=Universal Xport
MP 101 file vendor MASK_PATH vendor=DELL model=Universal Xport
MP 65535 runtime vendor NMP vendor=* model=*


[root@esx1 vmware]# esxcli corestorage claiming unclaim -t location -A vmhba33 -C 0 -T 0 -L 0


[root@esx1 vmware]# esxcfg-mpath -L
vmhba32:C0:T0:L0 state:active mpx.vmhba32:C0:T0:L0 vmhba32 0 0 0 NMP active local ide.vmhba32 ide.0:0
vmhba0:C0:T0:L0 state:active mpx.vmhba0:C0:T0:L0 vmhba0 0 0 0 NMP active local pscsi.vmhba0 pscsi.0:0
vmhba33:C0:T0:L0 state:dead (no device) vmhba33 0 0 0 (unclaimed) dead san iqn.1998-01.com.vmware:esx1-0f770b14 00023d000001,iqn.2006-01.com.ope nfiler:tsn.b6998f7991b4,t,1
vmhba33:C0:T0:L1 state:active t10.F405E46494C45400A645A56644F6D23626A435D207248425 vmhba33 0 0 1 NMP active san iqn.1998-01.com.vmware:esx1-0f77 0b14 00023d000001,iqn.2006-01.com.openfiler:tsn.b6998f7991b4,t,1
[root@esx1 vmware]#


No comments: