Tuesday, October 5, 2010

CentOS 5.5 iSCSI target setup with TGT

I wanted a template I could add to Lab Manager so it would auto start with a new hostname and IP address every time, I used CentOS 5.5 because there is a RedHat 5 64bit tools for guest customization already available.  I created a VM with a 10GB system and a 40GB data drive based off of RH5x64. 

There are many good guides to get TGT installed and working, this was probably the best one. 

I still had quite a few issues, but here is some good info that helped me sort it all out.

If your like me, doing something one time is nice, but ultimately not useful, you need this service to auto-start or it’s pretty much useless, therefore I think the tgtadm anc tgt-admin commands are only good for testing/setup.

Most of the guides have you setup a test file that you mount, that’s great for testing, but I wanted to map a whole physical (vm) drive, for me that was /dev/sdb.  I thought for a while my problem was that I needed to partition that drive i.e. /dev/sdb1, but luckily that isn’t necessary, I tested it both ways.

All I really needed to do was this:

1) Install TGT – yum install scsi-target-utils

2) make the tgtd service auto start - chkconfig tgtd on

3) make the firewall auto-stop (this is a lab application) - chkconfig iptables off

4) modify the /etc/tgt/targets.conf file to look something like this:

<target iqn.2008-09.com.example:server.target1>
    backing-store /dev/sdb

5) reboot and your done.


Here are some useful commands for testing:

Show what your current setup looks like (this is the most useful of the tgtadm commands = 

tgtadm --lld iscsi --op show --mode target

The second most useful is this one, it reloads your TGT from the targets.conf file so you can see if you have it working right =

tgt-admin –e


The rest are mildly useful.

Setup a test target = tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2001-04.com.1234:example

Setup a test LUN on above target = tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb

Allow all IP’s to use your target = tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL                     (theoretically this is not needed per all documentation, but I found otherwise)

1 comment:

chandra said...

The steps were very clear and informative! Am doing my TGT and this was very helpful..thanks for sharing!

Network Analyst Job Description