iSCSI target and initiator

A couple of years ago, I took a class which covered how to setup an iSCSI server and client. I don't have the book from that class handy, but some quick searching of the Internet helped me to recall these things.

In Redhat based distributions, the following command should be run to ensure that the needed software packages are installed:

yum install iscsi-initiator-utils.i686 scsi-target-utils.i686

On the iSCSI server, the following commands will start the SCSI target daemon and enable it to start automatically in the future:

service tgtd start
chkconfig tgtd on

In the following example, a server with a hostname "server" has an already created partition named /dev/sda3 that will be made available to clients as a target with the full name: iqn.2001-04.com-server-red-target.

tgt-setup-lun -n red-target /dev/sda3

Since the tgt-setup-lun command above did not limit clients by specifying a list of clients at the end of the command, all clients should be able to do the following to connect:

service iscsi start
chkconfig iscsi on
service iscsid start
chkconfig iscsid on
iscsiadm -m discovery -t st -p ${IP_ADDR_SERVER}
iscsiadm -m node -T iqn.2001-04.com-server-red-target -p ${IP_ADDR_SERVER} -l

Now, the "blkid" command should show a new /dev/sd# on the client that can be mounted.
The following command will show that any established sessions:

iscsiadm -m session

To stop a session, first the device should be unmounted "umount /dev/sd#", and then the following command logs the client out of the session:

iscsiadm -m node -T iqn.2001-04.com-server-red-target -p ${IP_ADDR_SERVER} -u

To make a iSCSI device mounted persistently, add _netdev for mount options in /etc/fstab.

1 comment:

Keith Wright said...

BTW, think of the server as the iSCSI target and the client as the iSCSI initiator.

About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.