A note of advice:
Whatever device you
setup to be shared out as an iSCSI device, must not be mounted on the server. If it is
mounted, you will not see it when you run the command tgt-admin –show!
Server steps used:
- yum install scsi-target-utils perl-Config-General
- service tgtd start
- chkconfig tgtd on
- add the following lines to /etc/tgt/targets.conf
<target
iqn.2012-05.com.example.server1:data>
backing-store
/dev/sdb1 #LUN1
write-cache
off
</target>
- service tgtd restart
- tgt-admin –show
you
should see output similar to the following
Target
1: iqn.2011-07.com.example.server1:trial
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 20000 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /dev/sdb1
To mount the newly
create iSCSI luns on the client follow these steps on the client:
- yum install iscsi-initiator-utils
- service iscsid start
- chkconfig iscsid on
- run the following commands to discover and connect to the lun on the server
- iscsiadm –mode discovery –type sendtargets –portal 192.168.1.10
- you will see output similar to the following:
- 192.168.1.10:3260,1 iqn.2012-05.com.example.server1:data
- iscsiadm –m node –T iqn.2012-05.com.example.server1:data –p 192.168.1.10 –l
- Logging in to [iface: default, target: iqn.2012-05.com.example.server1:data, portal: 192.168.1.10,3260]
- You should now see a new device listed in fdisk. Something along the lines of /dev/sdb1 if you only have 1 hdd in the server
- You are now ready to mount /dev/sdb1
- To mount the filesystem run the following commands:
- mkdir /data
- mount /dev/sdb1 /data
- If you want to make the mount point persistant, add the following line to /etc/fstab:
- /dev/sdb1 /data ext4 defaults 0 0