Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


May 16, 2008

Q. How can I use the command line to configure iSCSI connections?


RSS
Subscribe to Windows IT Pro | See More Scripting Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. I recently had a client who tried to use iSCSI to connect Server Core to SAN storage but couldn't get it to work without the iSCSI Initiator Control Panel applet. You can use the Iscsicli command-line interface to manage iSCSI. The first thing you need to do is enable iSCSI service and set it to start automatically, as you’ll see in the following code and corresponding output. The first command I entered was:

Users\john>sc config msiscsi start= auto

The output was:

[SC] ChangeServiceConfig SUCCESS

Then I entered:

Users\john>net start msiscsi

The output was:

The Microsoft iSCSI Initiator Service service is starting.
The Microsoft iSCSI Initiator Service service was started successfully.

Then, you use the Iscsicli command-line interface to connect to an iSCSI Target and list the available targets. The command I entered was:

Users\john>iscsicli QAddTargetPortal 192.168.1.31

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 
The operation completed successfully.

Next I entered:

Users\john>iscsicli ListTargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Targets List:
quorum
data
The operation completed successfully.

You can then connect to a target using the following code as an example:

Users\john>iscsicli qlogintarget data

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 
Session Id is 0xfffffa800626e018-0x4000013700000006
Connection Id is 0xfffffa800626e018-0x5
The operation completed successfully.

The following code checked to make sure the operation was successful:

Users\john>iscsicli reporttargetmappings

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Total of 1 mappings returned
Session Id : fffffa800626e018-4000013700000006
Target Name : data
Initiator : Root\ISCSIPRT\0000_0
Initiator Scsi Device : \\.\Scsi4:
Initiator Bus : 0
Initiator Target Id : 0
Target Lun: 0x0 <--> OS Lun: 0x0

The operation completed successfully.

You log out by using the logouttarget switch with the session ID, as the following sample code shows:

Users\john>iscsicli logouttarget fffffa800626e018-4000013700000006

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

The operation completed successfully.

To confirm the operation was successful, I entered the following code:

Users\john>iscsicli reporttargetmappings

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

No Mappings
The operation completed successfully.

The mappings obtained through the qlogintarget command aren’t persistent and will be lost at reboot. If you want a persistent connection, use the perssitenlogintarget switch, as the following code shows:

Users\john>iscsicli persistentlogintarget data T * * * * * * * * * * * * * * * 0

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

The operation completed successfully.

To confirm that the operation was successful, I entered:

Users\john>iscsicli listpersistenttargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

Total of 1 peristent targets
Target Name : data
Address and Socket : 192.168.1.31 3260
Session Type : Data
Initiator Name : Root\ISCSIPRT\0000_0
Port Number :
++Security Flags : 0x0
++Version : 0
++Information Specified: 0x20
++Login Flags : 0x8
++Username :

The operation completed successfully.

Entering T * * * * * * * * * * * * * * * 0 specifies all the required switches. To remove a persistent target, apply the information obtained from the listpersistentargets command, using the following code as an example:

Users\john>iscsicli removepersistenttarget Root\ISCSIPRT\0000_0 data * 192.168.1.31 3260

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 

The operation completed successfully.

To confirm the success of the operation, I entered:

Users\john>iscsicli listpersistenttargets

The output was:

Microsoft iSCSI Initiator Version 6.0 Build 6000 
Total of 0 peristent targets
The operation completed successfully.

You'll notice that I passed the initiator name first, then the target name, the port number (which is *), and last of all the iSCSI target server IP address and socket.

Using the Microsoft iSCSI Initiator CLI

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 24, 2008

An often irreverent look at some of the week's other news, including a Vista Capable dismissal request, Zune price reductions, Morrow musings, Novell and Microsoft sitting in a tree ... two years later, Yahoo!, IE 6 on Windows Mobile, and so much more ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing