SAN/iSCSI > SAN/iSCSI/open-iscsi
Debian as an iSCSI Initiator
This page focus on the open-iscsi.com Initiator (package open-iscsi). Reminder: The initiator is the "client".
Quickstart
Install the software
The module in iscsi_tcp is shipped in Debian's standard kernel since etch. So you'll just have to install open-iscsi.
Using
Let's query the target (server) about the service it knows
iscsiadm --mode discovery --type sendtargets --portal 192.168.0.20 192.168.0.1:3260,1 iqn.2007-01.org.debian.foobar:CDs 192.168.0.1:3260,1 iqn.2007-01.org.debian.foobar:USB
Next let's open a session to a given target:
iscsiadm --mode node --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal "192.168.0.1:3260" --login
Verify that an iscsi session has been created:
iscsiadm --mode session --print=1
If the session is successfully started, a new /dev/sdx device will show up, automatically linked to /dev/disk/by-path/ip-*. You can then use that device as if it were a regular disk.
You can then mount the new device, but under most situation, you will want to use LABEL= syntax in /etc/fstab (see e2label).
#device mount point FS Options Backup fsck LABEL=data1 /mnt/data1 ext3 _netdev 0 0
Once you have finished working, you can release the iSCSI target.
iscsiadm --mode node --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal "192.168.0.1:3260" --logout
Login to iscsi targets on boot
verify that after a successfull discovery (see iscsiadm --mode discovery --type sendtargets command above) you have node entries created for the discovered targets in /etc/iscsi/nodes
# ls /etc/iscsi/nodes/ iqn.2003-01.org.linux-iscsi.blip:target0
for each discovered target, set in /etc/iscsi/nodes/<target-iqn>/default the node.startup parameter to automatic
restart the open-iscsi service. You should see the new devices with the lsscsi/lsblk command line tools now and after each boot
# systemctl restart open-iscsi.service
# lsscsi --transport [7:0:0:0] disk iqn.2003-01.org.linux-iscsi.blip:target0,t,0x1 /dev/sdc
Using authentication
You can configure in /etc/iscsi/iscsid.conf:
- discovery.sendtargets.auth.authmethod = CHAP
- discovery.sendtargets.auth.username = jdoe
discovery.sendtargets.auth.password = YourSecurePwd1
- node.session.auth.authmethod = CHAP
- node.session.auth.username = jdoe
node.session.auth.password = YourSecurePwd1
and possibly:
- node.startup = automatic
Please note that some targets cannot use a password for the discovery phase, while other targets only support the same password for both discovery and session phase.
Otherwise, you can also create a single connection (a file /etc/iscsi/nodes/iqn.2007-01.org.debian.foobar:CDs/192.168.0.1,3260 is automatically created)
iscsiadm --mode node --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal 192.168.0.1:3260 --op=update --name node.session.auth.authmethod --value=CHAP iscsiadm --mode node --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal 192.168.0.1:3260 --op=update --name node.session.auth.username --value=$Id iscsiadm --mode node --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal 192.168.0.1:3260 --op=update --name node.session.auth.password --value=$MDP iscsiadm --mode node --targetname "iqn.2007-01.org.debian.foobar:CDs" --portal 192.168.0.1:3260 --login
Finding out the iSCSI initiator's iqn
The iSCSI initiator also has an iqn which you will find in /etc/iscsi/initiatorname.iscsi. After installation of open-iscsi it just contains "GenerateName=yes". During the first start of the demon the iqn gets generated.
FAQ & common error messages
- ietd: CHAP initiator auth.: No valid user/pass combination for initiator iqn.1993-08.org.debian:01:123456789abcd found
- The initiator's user account and/or password is wrong !
iscsiadm: Login failed to authenticate with target
iscsiadm: discovery login to 192.168.0.20 rejected: initiator error (02/01), non-retryable, giving up ::wrong "discovery" username or password. - How does udev looks like ?
- udev won't help you mounting the device. use "LABEL=" in /etc/fstab instead.
$ udevinfo -a -p $(udevinfo -q path -n /dev/sdb) looking at parent device '/devices/platform/host98/session1/target98:0:0/98:0:0:2': KERNELS=="98:0:0:2" SUBSYSTEMS=="scsi" DRIVERS=="sd" ATTRS{modalias}=="scsi:t-0x00" ATTRS{ioerr_cnt}=="0x0" ATTRS{iodone_cnt}=="0x1f" ATTRS{iorequest_cnt}=="0x1f" ATTRS{iocounterbits}=="32" ATTRS{timeout}=="30" ATTRS{state}=="running" ATTRS{rev}=="0 " ATTRS{model}=="VIRTUAL-DISK " ATTRS{vendor}=="IET " ATTRS{scsi_level}=="5" ATTRS{type}=="0" ATTRS{queue_type}=="none" ATTRS{queue_depth}=="32" ATTRS{device_blocked}=="0"
See also
- open-iscsi Initiator.