Get the iSCSI iqn of an ESX(i) using the CLI

December 13, 2010 — 4 Comments

When you are trying to configure iSCSI of and ESX(i) server from the command line is clear that at some point you are going to need the iqn. Of course you can  use the vSphere Client to get the iqn but the Unix Geek inside me really wants to do it from the shell.

After a small research through the vSphere CLI documentation and several blogs I found this post by Jon Owings (@2vcps).

First list the SCSI devices available in the system to get the iSCSI hba.

[root@esx02 ~]# esxcfg-scsidevs -a
vmhba0  mptspi            link-n/a  pscsi.vmhba0                            (0:0:16.0) LSI Logic / Symbios Logic LSI Logic Parallel SCSI Controller
vmhba1  ata_piix          link-n/a  ide.vmhba1                              (0:0:7.1) Intel Corporation Virtual Machine Chipset
vmhba32 ata_piix          link-n/a  ide.vmhba32                             (0:0:7.1) Intel Corporation Virtual Machine Chipset
vmhba33 iscsi_vmk         online    iscsi.vmhba33                           iSCSI Software Adapter         
[root@esx02 ~]#

After that Jon uses the command vmkiscsi-tool to get the iqn.

[root@esx02 ~]# vmkiscsi-tool -I -l vmhba33
iSCSI Node Name:
[root@esx02 ~]#

Beauty, isn’t it? But I found one glitch. This method is done from the ESX root shell but how do I get the iqn from the vMA? Some of my hosts are ESXi and even for the ESX I use the vMA to perform my everyday administration tasks.

There is no vmkiscsi-tool command in the vMA, instead we are going to use the vicfg-iscsi or the vicfg-scsidevs command.

With vicfg-scsidevs we can obtain the iqn listed in the UID colum.

[vi-admin@vma ~][esx02.mlab.local]$ vicfg-scsidevs -a             
Adapter_ID  Driver      UID                                     PCI      Vendor & Model
vmhba0      mptspi      pscsi.vmhba0                            (0:16.0) LSI Logic Parallel SCSI Controller
vmhba1      ata_piix    unknown.vmhba1                          (0:7.1)  Virtual Machine Chipset
vmhba32     ata_piix    ide.vmhba32                             (0:7.1)  Virtual Machine Chipset
vmhba33     iscsi_vmk   ()       iSCSI Software Adapter
[vi-admin@vma ~][esx02.mlab.local]$

And with vicfg-iscsi we can get the iqn providing the vmhba device.

[vi-admin@vma ~][esx02.mlab.local]$ vicfg-iscsi --iscsiname --list vmhba33
iSCSI Node Name   :
iSCSI Node Alias  :
[vi-admin@vma ~][esx02.mlab.local]$

The next logical step is to use PowerCLI to retrive the iqn, but I’ll leave that for a future post.



4 responses to Get the iSCSI iqn of an ESX(i) using the CLI


    Awesome! Thanks for the post!


    VMware Certified Advanced Professional 6 (Desktop and Mobility Deployment) – The industry-recognized VCAP6-DTM Deploy certification validates that you know how to deploy and optimize VMware Horizon 6 (with View) environments. It demonstrates that you have the understanding and skills necessary to leverage best practices to provide a scalable and reliable Business Mobility platform for your company. Some of the subject areas involve: Configuring and managing Horizon View components, configuring cloud pod archituecture, configuring Group Policy settings related to Horizon View, Configuring and optimizing desktop images for Horizon View & Mirage, Configuring and managing App Volumes AppStacks, Configuring desktop pools, Configuring and deploying ThinApp packaged applications, Configuring VMWare Identity Manager, etc.Sebastian’s take on the VCAP6 examination: “In my own thoughts and opinions VCAP6 exam is way better experience as compared with VCAP5, the newest exam appears just like VMware HOL. The user interface is effortless, questions are ordered on the right section of the screen, and can be concealed aside or even restored when required. My advise on the questions windowpane: if you would like make it floating, you must know how to restore it back. I ended up shifting it around for the reason that I forget how to restore it back. The 2 arrows that looked like control buttons on the top were intended to dock the window to right of left. Fonts can be resized, which i think was a lot better than scrolling up and down the question. The response speed of the whole user interface was so noticeably faster than VCAP5.5, and there wasn’t any lagging time experienced when switching from window to window. One thing to remember: BACKSPACE key is not working! I think this is good because you don’t reload your examination window by mistake, on the other hand, it could be frustrating occasionally whenever you type something wrongly and you need to select and press Del to remove. The Desktop and shortcuts were arranged very nicely, and all essential programs like browser or Mirage console can easily be launched. You will find a superb interface for Remote Desktop Manager where you can find all essential RDP connection to servers or desktops with no need to type username and password. The web browser had all the links in the Favorite Bar. Right at that moment I’m writing this, there’s no extra Thirty minute extension for Non-Native English speaker at No-Native English country, which is actually a bummer. There are 39 question to respond to within the three hours period, and this can be actually really hard for non-native English speakers like me. Quite a few questions take time to finish, so it is best to pass by the questions that you cannot answer, and finish those you are able to. At the end of the 39 questions, you’ll be able to visit the uncompleted questions if you still have time. Don’t waste too much time on one single question! The exam blue print is found on my website at It is well-organized and following it for the exam preparation can really help a great deal. Needless to say, the best is if you could have a lot of practical experience! I’m in fact pretty pleased with the examination experience, though I passed this time around by tiny margin, however i really know what I missed for the exam, learn from the blunders and practice harder to familiarise myself with the environment. This credentials is going to open up your job prospects!”

Trackbacks and Pingbacks:

  1. VMware Communities: If I set up an openfiler VM as an iSCSI … :: My Asia Delight - December 21, 2010

    […] Get the iSCSI iqn of an ESX(i) using the CLI « Juanma's Blog […]

  2. How to get iSCSI iqn using esxcli in ESXi 5 « Juanma's Blog - August 2, 2012

    […] in 2010 I wrote a post about how to get the iSCSI iqn of an ESXi 4.x server using vSphere CLI from the vMA or any other system with the vCLI installed on […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s