Sometimes, I find it better/faster/easier to perform tasks from the command-line interface (CLI) than going through a GUI. So, the other day, I needed to setup a new VMware ESX Server for iSCSI storage, and thought I’d document the commands I used to set that up.
Unfortunately, the commands weren’t able to do all the configuration I needed—I couldn’t find the commands to let me set iSCSI security (CHAP username and password), and I needed iSCSI security for the target to which I was connecting. However, these commands should work just fine for a basic iSCSI configuration.
Here are the commands I used:
Enables the software iSCSI initiator.
esxcfg-firewall -e swISCSIClient
Configures the ESX Service Console firewall (iptables) to allow the software iSCSI traffic.
vmkiscsi-tool -D -a 192.168.100.50 vmhba40
Sets the target IP address for the vmhba40 adapter (the software iSCSI initiator).
Rescans for storage devices on vmhba40.
I’m sure there are more commands available; for more information, you can refer to Mike Laverick’s excellent Guide to ESX 3 Service Console. In addition, please note that the ESX Server software iSCSI initiator is simply the open source version of an old Cisco iSCSI initiator for Linux, so you can use that command reference as well (I believe this information is also applicable). Just preface the commands from the CuddleTech article with â€œvmkâ€ and it should work just as listed.
One oddity: you may find that some of the command-line tools will report a Cisco IQN, but after further configuration (and especially after configuration from VirtualCenter) it will switch to a VMware IQN. This may wreak havoc with iSCSI targets on which LUN presentation is based on IQN names, so plan accordingly.