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.
After that Jon uses the command vmkiscsi-tool to get the iqn.
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 column.
And with vicfg-iscsi we can get the iqn providing the vmhba device.
The next logical step is to use PowerCLI to retrieve the iqn, but I’ll leave that for a future post.