Define an iscsi target name
The following example creates a target with id 1 (the iqn is 19 iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz) and adds a 20 logical unit (backed by /dev/hdc1) with lun 1.# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
To view the current configuration, enter:# tgtadm --lld iscsi --op show --mode target
Sample output:
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz System information: Driver: iscsi Status: running I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 Online: No Poweron/Reset: Yes Removable media: No Backing store: No backing store Account information: ACL information:
Add a logical unit to the target (/dev/sdb1):# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1
A note about home computer / test system
Most production boxes will only use iSCSI root with real iSCSI devices, but for testing purposes it can be quite useful to set up an iSCSI target on your image server. This is useful for testing and learning iSCSI target and iSCSI initiator at home, simply use filesystem for testing purpose. Use dd command to create diskbased filesystem:# dd if=/dev/zero of=/fs.iscsi.disk bs=1M count=512
Add /fs.iscsi.disk as a logical unit to the target:# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /fs.iscsi.disk
Now, you should able to view details:# tgtadm --lld iscsi --op show --mode target
Sample output:
Target 1: iqn.2001-04.com.example:storage.disk1.amiens.sys1.xyz System information: Driver: iscsi Status: running I_T nexus information: LUN information: LUN: 0 Type: controller SCSI ID: deadbeaf1:0 SCSI SN: beaf10 Size: 0 Online: No Poweron/Reset: Yes Removable media: No Backing store: No backing store LUN: 1 Type: disk SCSI ID: deadbeaf1:1 SCSI SN: beaf11 Size: 512M Online: Yes Poweron/Reset: Yes Removable media: No Backing store: /fs.iscsi.disk Account information: ACL information:
Accept iSCSI Target
To enable the target to accept any initiators, enter:# tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
This should open network port # 3260:# netstat -tulpn | grep 3260
Sample output:
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 27328/tgtd tcp6 0 0 :::3260 :::* LISTEN 27328/tgtd
And you are done. Your system is configured as iSCSI Target. Remote client computer can access this computers hard disk over network. Your can use cluster aware filesystem to setup real shared storage for small business. Open TCP port 3260 in your firewall, if required.
Comments
Post a Comment