Menu
InformatiWeb Pro
  • Index
  • System admin
  • Virtualization

Login

Registration Password lost ?
FR
  • Windows Server
    • WMS 2012
    • WS2012 R2
    • WS2016
  • Citrix
    • Citrix NetScaler Gateway
    • Citrix XenApp / XenDesktop
    • Citrix XenServer
  • VMware
    • VMware ESXi
    • VMware vSphere
    • VMware Workstation
  • Microsoft
    • Hyper-V
  • RAID
    • Adaptec SmartRAID
  • UPS
    • APC Back-UPS Pro
  • InformatiWeb Pro
  • Virtualization
  • VMware
  • Mask an iSCSI LUN (iSCSI disk) on VMware vSphere 6.7
  • VMware
  • VMware vCenter Server (VCSA), VMware vSphere
  • 11 September 2024 at 13:42 UTC
  • InformatiWeb

Mask an iSCSI LUN (iSCSI disk) on VMware vSphere 6.7

By default, when you add an iSCSI server or iSCSI target in the iSCSI controller configuration of your VMware ESXi host, all iSCSI disks in that iSCSI target are visible to your VMware ESXi host.
However, it is possible to hide iSCSI disks directly on your VMware ESXi host using the command line (SSH).

  1. iSCSI LUN to mask
  2. Mask an iSCSI LUN
  3. Unmask an iSCSI LUN

1. iSCSI LUN to mask

For this tutorial, we created 2 iSCSI disks on our iSCSI server on Windows Server.
We have also created a datastore on each of them.

In this tutorial, we will mask the 300 GB iSCSI disk on which we created the "iSCSI Datastore 2" datastore.

As you can see, at the moment our host "esxi1" is seeing the datastore "iSCSI Datastore 2" at the moment.

2. Mask an iSCSI LUN

To get started, enable SSH on your VMware ESXi host.
To do this, select your VMware ESXi host and go to "Configure -> System -> Services".
Next, start the "SSH" service.

Connect to your VMware ESXi host via SSH using PuTTY.

To find the LUN ID to hide, use the command:

Plain Text

esxcli storage core device list | less

Browse the result using the "up" and "down" arrows or using the "previous page" and "next page" keys on the keyboard.
The identifier you need to retrieve is the one that begins the section corresponding to the desired LUN.
Usually, this one starts with "naa." (as you can see below).
For iSCSI disks created on an iSCSI server on Windows Server, the name is always "MSFT iSCSI Disk".
In our case, we will hide our 300 GB iSCSI disk (Size: 307200).

Note: press "Q" to exit this command.

Note that you can view only this disk's information, if desired, using the command below.
The identifier indicated via the "-d" parameter corresponds to the identifier retrieved via the previous command.

Plain Text

esxcli storage core device list -d naa.60003ff44dc75adc8f75aa07ab8c2b28

Now that you have the ID of the LUN to hide, view the list of path claim rules:

Plain Text

esxcli storage core claimrule list

As you can see, 2 plugins are used by default:

  • NMP: for access to USB, SATA, IDE, BLOCK (iSCSI) and unknown devices.
    If the device does not match any of the rules in this list, the NMP plugin will be used (using rule #65535).
  • MASK_PATH: to hide DELL devices whose model is "Universal Xport".

As noted in the VMware documentation, claim rules for hiding paths have rule IDs between 101 and 200.
In our case, number 102 is not used. So we will use this for our new rule.

Note that LUNs can be hidden by path, transport type, and vendor.
In our case, we will hide a specific LUN using its path.

Obtain the available paths for the LUN you want to hide by typing this command.
Note: the "naa...." value indicated here corresponds to the identifier of the LUN retrieved previously.

Plain Text

esxcfg-mpath -m | grep naa.60003ff44dc75adc8f75aa07ab8c2b28

Plain Text

vmhba65:C0:T0:L1 vmhba65 iqn.1998-01.com.vmware:esxi1-417c78c0 00023d000001,iqn.1991-05.com.microsoft:iscsi-server-informatiweb-iscsi-server-target,t,1 naa.60003ff44dc75adc8f75aa07ab8c2b28

Create a new path claim rule using the command below.

  • -P MASK_PATH: indicates that the plug-in to use is "MASK_PATH" which is a plug-in under VMware ESXi allowing you to mask iSCSI LUNs
  • -r 102: indicates that the rule created will have the number 102.
  • -t location: Indicates that the type that will be used is "location", as stated in the VMware documentation.
  • -A vmhba65: indicates that the adapter used under VMware ESXi is "vmhba65".
    This value, as well as the following ones (C, T and L) are displayed by the previous command.
  • -C 0: indicates that the channel used is "0".
  • -T 0: indicates that the target used is "0".
  • -L 1: indicates that the LUN number used is "1".

Plain Text

esxcli storage core claimrule add -P MASK_PATH -r 102 -t location -A vmhba65 -C 0 -T 0 -L 1

Load the added claim rule for the MASK_PATH plugin using the command:

Plain Text

esxcli storage core claimrule load

Verify that the new claim rule has been added.

Plain Text

esxcli storage core claimrule list

As you can see, the rule has been added 2 times:

  • Class - runtime: rule currently used (runtime = execution).
  • Class - file: rule also added in the configuration file.

If a claim rule already exists for the hidden path, delete it (as noted in the VMware documentation).
Note: "-A vmhba65" allows you to specify the adapter used as previously.

Plain Text

esxcli storage core claiming unclaim -t location -A vmhba65

Run path claim rules.

Plain Text

esxcli storage core claimrule run

Finally, type this command to make the desired LUN disappear from your VMware ESXi host.
Note: the value "naa...." again corresponds to the identifier of the LUN that you wish to hide.

Plain Text

esxcli storage core claiming reclaim -d naa.60003ff44dc75adc8f75aa07ab8c2b28

To verify that this LUN has been hidden, type the command below.
If this command returns nothing, the LUN has been successfully hidden.

Plain Text

esxcfg-mpath -m | grep naa.60003ff44dc75adc8f75aa07ab8c2b28

In the VMware vSphere Client, select your VMware ESXi host and go to "Storage -> Storage Adapters".
Select your iSCSI controller and go to the "Devices" tab (at the bottom of the page).
The hidden LUN is gone.

The "iSCSI Datastore 2" datastore that was on this LUN in our case has also disappeared.

Sources :

  • Mask Paths - VMware Docs
  • Masking a LUN from ESX and ESXi using the MASK_PATH plug-in (1009449)

3. Unmask an iSCSI LUN

If you want to redisplay a LUN that was previously hidden, first display the list of path claims rules.

Plain Text

esxcli storage core claimrule list

Locate the complaint rule that you want to delete and whose plugin must be "MASK_PATH".
In our case, it is rule #102.

Delete the complaint rule by indicating its number as a parameter.

Plain Text

esxcli storage core claimrule remove -r 102

Display the list of path claims rules again.

Plain Text

esxcli storage core claimrule list

As you can see, the line whose class was "file" has been deleted.
Which indicates that the rule has been deleted from the configuration file.
However, it is still used by the process that manages them since there is one line left for this rule with the "runtime" class.

To no longer use this rule, simply reload the claim rules from the configuration file.

Plain Text

esxcli storage core claimrule load

Now the claim rule has disappeared from the list entirely.

Plain Text

esxcli storage core claimrule list

To make the LUN reappear, use the command below specifying:

  • -A vmhba65: the name of the adapter where it was located.
  • -C 0: the channel used for this LUN
  • -T 0: the target used for this LUN
  • -L 1: the number of this LUN

Note: these values were indicated in the "Matches" column of the list of path claim rules.

Plain Text

esxcli storage core claiming unclaim -t location -A vmhba65 -C 0 -T 0 -L 1

Finally, run the path claim rules.

Plain Text

esxcli storage core claimrule run

To check if this LUN is visible again, use the command:

Plain Text

esxcfg-mpath -L | egrep "vmhba65:C0.*L1"

In our case, our LUN is displayed:

Plain Text

vmhba65:C0:T0:L1 state:active naa.60003ff44dc75adc8f75aa07ab8c2b28 vmhba65 0 0 1 NMP active san iqn.1998-01.com.vmware:esxi1-417c78c0 00023d000001,iqn.1991-05.com.microsoft:iscsi-server-informatiweb-iscsi-server-target,t,1

If you view the list of devices connected to your iSCSI controller, you will see that your LUN has reappeared.
In our case, this is the 300 GB LUN where the "iSCSI Datastore 2" datastore was located.

As expected, the "iSCSI Datastore 2" datastore reappears on our host "esxi1".

Source : Unmask Paths - VMware Docs.

Share this tutorial

Partager
Tweet

To see also

  • VMware ESXi 6.7 - Make virtual machines unique

    VMware 9/23/2022

    VMware ESXi 6.7 - Make virtual machines unique

  • VMware ESXi 7.0 / 6.7 - Boot a VM on the BIOS / EFI firmware

    VMware 8/12/2022

    VMware ESXi 7.0 / 6.7 - Boot a VM on the BIOS / EFI firmware

  • VMware ESXi 7.0 / 6.7 - Extend a datastore (on a second hard drive)

    VMware 8/5/2022

    VMware ESXi 7.0 / 6.7 - Extend a datastore (on a second hard drive)

  • VMware vSphere 6.7 - Clone virtual machines

    VMware 10/4/2024

    VMware vSphere 6.7 - Clone virtual machines

Comments

You must be logged in to post a comment

Share your opinion

Pinned content

  • Software (System admin)
  • Linux softwares
  • Our programs
  • Terms and conditions
  • Share your opinion

Contact

  • Guest book
  • Technical support
  • Contact

® InformatiWeb-Pro.net - InformatiWeb.net 2008-2022 - © Lionel Eppe - All rights reserved.

Total or partial reproduction of this site is prohibited and constitutes an infringement punishable by articles L.335-2 and following of the intellectual property Code.