0. First, a block device should be availablenode
linux-lokb:~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vdb 254:16 0 100G 0 diskpython
1. start "targetcli" and execute "ls"linux
linux-lokb:~ # targetcli
/usr/lib/python2.7/site-packages/targetcli/ui_node.py:20: UserWarning: 'configshell' package name for configshell-fb is deprecated, please instead import 'configshell_fb'
from configshell import ConfigNode, ExecutionError
Loaded iscsi_target_mod kernel module.
Created '/sys/kernel/config/target/iscsi'.
Loaded vhost_scsi kernel module.
Created '/sys/kernel/config/target/vhost'.
Loaded tcm_qla2xxx kernel module.
Created '/sys/kernel/config/target/qla2xxx'.
Loaded tcm_fc kernel module.
Created '/sys/kernel/config/target/fc'.
Loaded tcm_loop kernel module.
Created '/sys/kernel/config/target/loopback'.
Loaded ib_srpt kernel module.
Created '/sys/kernel/config/target/srpt'.
targetcli 2.1-suse (rtslib 2.2-sle12)
Copyright (c) 2011-2014 by Datera, Inc.
All rights reserved.shell
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- fileio ................................................................................................... [0 Storage Object]
| o- iblock ................................................................................................... [0 Storage Object]
| o- pscsi .................................................................................................... [0 Storage Object]
| o- rbd ...................................................................................................... [0 Storage Object]
| o- rd_mcp ................................................................................................... [0 Storage Object]
o- ib_srpt ........................................................................................................... [0 Targets]
o- iscsi ............................................................................................................. [0 Targets]
o- loopback .......................................................................................................... [0 Targets]
o- qla2xxx ........................................................................................................... [0 Targets]
o- tcm_fc ............................................................................................................ [0 Targets]
o- vhost ............................................................................................................. [0 Targets]
/>session
2. Create a iblock storage object "iscsi_vdb"python2.7
/> backstores/iblock create name=icsi_vdb dev=/dev/vdb
Generating a wwn serial.
Created iblock storage object icsi_vdb using /dev/vdb.
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- fileio ................................................................................................... [0 Storage Object]
| o- iblock ................................................................................................... [1 Storage Object]
| | o- icsi_vdb ........................................................................................... [/dev/vdb deactivated]
| o- pscsi .................................................................................................... [0 Storage Object]
| o- rbd ...................................................................................................... [0 Storage Object]
| o- rd_mcp ................................................................................................... [0 Storage Object]
o- ib_srpt ........................................................................................................... [0 Targets]
o- iscsi ............................................................................................................. [0 Targets]
o- loopback .......................................................................................................... [0 Targets]
o- qla2xxx ........................................................................................................... [0 Targets]
o- tcm_fc ............................................................................................................ [0 Targets]
o- vhost ............................................................................................................. [0 Targets]
tcp
3. Create iscsi targetoop
/> iscsi/ create
Created target iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d.
Selected TPG Tag 1.
Created TPG 1.
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- fileio ................................................................................................... [0 Storage Object]
| o- iblock ................................................................................................... [1 Storage Object]
| | o- icsi_vdb ........................................................................................... [/dev/vdb deactivated]
| o- pscsi .................................................................................................... [0 Storage Object]
| o- rbd ...................................................................................................... [0 Storage Object]
| o- rd_mcp ................................................................................................... [0 Storage Object]
o- ib_srpt ........................................................................................................... [0 Targets]
o- iscsi .............................................................................................................. [1 Target]
| o- iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d ........................................................ [1 TPG]
| o- tpg1 ............................................................................................................ [enabled]
| o- acls ........................................................................................................... [0 ACLs]
| o- luns ........................................................................................................... [0 LUNs]
| o- portals ..................................................................................................... [0 Portals]
o- loopback .......................................................................................................... [0 Targets]
o- qla2xxx ........................................................................................................... [0 Targets]
o- tcm_fc ............................................................................................................ [0 Targets]
o- vhost ............................................................................................................. [0 Targets]
ui
4. Create "LUN 0"ip
/> cd iscsi/iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d/tpg1/
/iscsi/iqn.20...1c61364d/tpg1> luns/ create /backstores/iblock/icsi_vdb
Selected LUN 0.
Created LUN 0.
5. Setting parameters
/iscsi/iqn.20...1c61364d/tpg1> set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
Parameter demo_mode_write_protect is now '0'.
Parameter authentication is now '0'.
Parameter generate_node_acls is now '1'.
Parameter cache_dynamic_acls is now '1'.
6. Create portals
/iscsi/iqn.20...1c61364d/tpg1> portals/ create
Using default IP port 3260
Automatically selected IP address 192.168.101.169.
Created network portal 192.168.101.169:3260.
/iscsi/iqn.20...1c61364d/tpg1> ls
o- tpg1 .................................................................................................................. [enabled]
o- acls ................................................................................................................. [0 ACLs]
o- luns .................................................................................................................. [1 LUN]
| o- lun0 ........................................................................................... [iblock/icsi_vdb (/dev/vdb)]
o- portals ............................................................................................................ [1 Portal]
o- 192.168.101.169:3260 .................................................................................... [OK, iser disabled]
7. Save and exit
/iscsi/iqn.20...1c61364d/tpg1> cd /
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- fileio ................................................................................................... [0 Storage Object]
| o- iblock ................................................................................................... [1 Storage Object]
| | o- icsi_vdb ............................................................................................. [/dev/vdb activated]
| o- pscsi .................................................................................................... [0 Storage Object]
| o- rbd ...................................................................................................... [0 Storage Object]
| o- rd_mcp ................................................................................................... [0 Storage Object]
o- ib_srpt ........................................................................................................... [0 Targets]
o- iscsi .............................................................................................................. [1 Target]
| o- iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d ........................................................ [1 TPG]
| o- tpg1 ............................................................................................................ [enabled]
| o- acls ........................................................................................................... [0 ACLs]
| o- luns ............................................................................................................ [1 LUN]
| | o- lun0 ..................................................................................... [iblock/icsi_vdb (/dev/vdb)]
| o- portals ...................................................................................................... [1 Portal]
| o- 192.168.101.169:3260 .............................................................................. [OK, iser disabled]
o- loopback .......................................................................................................... [0 Targets]
o- qla2xxx ........................................................................................................... [0 Targets]
o- tcm_fc ............................................................................................................ [0 Targets]
o- vhost ............................................................................................................. [0 Targets]
/> saveconfig
WARNING: Saving linux-lokb current configuration to disk will overwrite your boot settings.
The current target configuration will become the default boot config.
Are you sure? Type 'yes': yes
/> ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- fileio ................................................................................................... [0 Storage Object]
| o- iblock ................................................................................................... [1 Storage Object]
| | o- icsi_vdb ............................................................................................. [/dev/vdb activated]
| o- pscsi .................................................................................................... [0 Storage Object]
| o- rbd ...................................................................................................... [0 Storage Object]
| o- rd_mcp ................................................................................................... [0 Storage Object]
o- ib_srpt ........................................................................................................... [0 Targets]
o- iscsi .............................................................................................................. [1 Target]
| o- iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d ........................................................ [1 TPG]
| o- tpg1 ............................................................................................................ [enabled]
| o- acls ........................................................................................................... [0 ACLs]
| o- luns ............................................................................................................ [1 LUN]
| | o- lun0 ..................................................................................... [iblock/icsi_vdb (/dev/vdb)]
| o- portals ...................................................................................................... [1 Portal]
| o- 192.168.101.169:3260 .............................................................................. [OK, iser disabled]
o- loopback .......................................................................................................... [0 Targets]
o- qla2xxx ........................................................................................................... [0 Targets]
o- tcm_fc ............................................................................................................ [0 Targets]
o- vhost ............................................................................................................. [0 Targets]
/> exit
8. Discovery and login
ericsp21:~ # iscsiadm -m discovery --type sendtargets --portal 192.168.101.169
192.168.101.169:3260,1 iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d
ericsp21:~ # iscsiadm -m node --targetname iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d -p 192.168.101.169 -o update -n node.startup -v automatic
ericsp21:~ # iscsiadm -m node --targetname iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d --portal 192.168.101.169 --login
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d, portal: 192.168.101.169,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d, portal: 192.168.101.169,3260] successful.
ericsp21:~ # iscsiadm -m session
tcp: [1] 192.168.101.169:3260,1 iqn.2003-01.org.linux-iscsi.linux-lokb.x8664:sn.2e8e1c61364d (non-flash)
ericsp21:~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
So, "sda" is our iscsi device