How to configure iSCSI

How to configure iSCSI initiator

]# iscsiadm -m discovery -t st -p 192.168.0.254
( m=mode, t= type, st=send targets, p=Portal )

]# iscsiadm -m node -T iqn.2010-09.com.example:rdisk.demo -p 192.168.0.254 -l
( T= target name, l=loging )

]# tailf /var/log/message ( to find device type eg. /dev/sda)

]# fdisk /dev/sda (make it primary or extended asper requirement )

]# mkfs.ext4 /dev/sda1

]# mkdir /storage

]# vim /etc/fstab

UUID=xxxxxx /storage ext4 _netdev 0 0

]# mount -a

------------------------------------------------------------------------------------
To Unmount iscsi initiator

]# vim /etc/fstab ( remove mount iscsi mount point )

]# umount /dev/sda1

]# iscsiadm -m node -T iqn.2010-09.com.example:rdisk.demo -p 192.168.0.254 -u
( u=logout )

]# iscsiadm -m node -T iqn.2010-09.com.example:rdisk.demo -p 192.168.0.254 -o delete
( -o delete = to delete )

-------------------------------------------------------------------

How to Configure iSCSI target ( iSCSI Server )

]# fdisk /dev/sda (create empty partition )

]# yum install scsi-target-utils

]# chkconfig tgtd on

]# service tgtd restart

]# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2011-06.com.example:storage.demo

]# tgtadm --lld iscsi --op show --mode target

]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/vda5

]# tgtadm --lld iscsi --op bind --mode target --tid 1 -I All

]# tgtadm --lld iscsi --op show --mode target

or

]# vim /etc/tgt/targets.conf


backing-store /dev/vda5
initiator-address ALL

]# service tgtd restart