iSCSI – Initiator and Target.

The target is the name of the iSCSI server. The iSCSI server offers its devices (disks, tape, dvd/cd, etc.) to the clients. One device can by accessed by a few clients.

At first we have to set up a target server:

debian# apt-get install iscsitarget iscsitarget-dkms

then edit the configuration file:

debian# vi /etc/default/iscsitarget

and then, set ISCSITARGET_ENABLE to true: “ISCSITARGET_ENABLE=true“.

Now, we can create a volume group:

debian# vgcreate vg1 /dev/sdc1

but before that, you have to use fdiks to create Linux LVM partition. The next step is to initializes PhysicalVolume for later use by the Logical Volume Manager (LVM):

debian# pvcreate /dev/sdc1

and then, create a logical volume in an existing volume group:

debian# lvcreate -L2000M -n disk_sdc vg1

Now, we can add the “sdc1” disk to /etc/iet/ietd.conf and comment out everything in that file.

Lun 0 Path=/dev/vg1/disk_sdc,Type=fileio
Alias LUN1
MaxConnections 0

and then, and start the target:

debian# /etc/init.d/./iscsitarget start

The initiator is the name of the iSCSI client. The iSCSI client has a block level access to the iSCSI devices, which can be a disk, tape drive, DVD/CD writer. One client can use multiple iSCSI devices.

To install the initiator:

debian# apt-get install open-iscsi

and then, edit the /etc/iscsi/iscsid.conf file, and set node.srartup to automatic

node.startup = automatic

and then, restart the initiator:

debian# /etc/init.d/./open-iscsi restart

Discover targets using the discovery record with the recid matching the the discovery type and portal passed in. If there is no matching record, it will be created using the iscsid.conf discovery settings. This must be passed in discoverydb mode to instruct iscsiadm to perform discovery. This option is only valid for SendTargets discovery mode.

To do this:

debian# iscsiadm -m discovery -t st -p


debian# iscsiadm -m discovery -t st -p,1

Specify the mode. op must be one of discoverydb, node, fw, host iface or session.
If no other options are specified: for discoverydb and node, all of their respective records are displayed; for session, all active sessions and connections are displayed; for fw, all boot firmware values are displayed; for host, all iSCSI hosts are displayed; and for iface, all ifaces setup in /var/lib/iscsi/ifaces are displayed.

and then:

debian# iscsiadm -m node

and finally we can log in, either by running:

iscsiadm -m node --targetname "" --portal "" --login

Ohh… that’s useful:

debian# cat /proc/net/iet/volume
debian# cat /proc/net/iet/vsession

Leave a Reply

Your email address will not be published. Required fields are marked *