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).
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.
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:
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.
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:
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 :
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:
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.
VMware 5/19/2023
VMware 8/2/2024
VMware 8/9/2024
VMware 8/23/2024
Pinned content
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.
You must be logged in to post a comment