iSCSI is used to connect storage devices in the network, it works on TCP/IP. It can be used with in local area network (LAN), wide area network (WAN), or the Internet. iSCSI devices are disks, tapes, DVDs, and other storage devices on another networked computer that you can connect to.
SCSI Addressing
Linux has a four level hierarchical addressing scheme for SCSI devices:
- SCSI adapter number [host]
- channel number [bus]
- id number [target]
- lun [lun]
“Lun” is the common SCSI abbreviation of Logical Unit Number. The terms in brackets are the name conventions used by device pseudo file system (devfs). “Bus” is used in preference to “channel” in the description below.
The SCSI adapter number is typically an arbitrary numbering of the adapter cards on the internal IO buses (e.g. PCI, PCMCIA, ISA etc) of the computer. Such adapters are sometimes termed as HBAs (host bus adapters). SCSI adapter numbers are issued by the kernel in ascending order starting with 0.
Each HBA may control one or more SCSI buses. The various types of SCSI buses are listed in Appendix A.
Each SCSI bus can have multiple SCSI devices connected to it. In SCSI parlance the HBA is called the “initiator” and takes up one SCSI id number (typically 7). The initiator [1] talks to targets which are commonly known as SCSI devices (e.g. disks). On SCSI parallel buses the number of ids is related to the width. 8 bit buses (sometimes called “narrow”) can have 8 SCSI ids of which 1 is taken by the HBA leaving 7 for SCSI devices. Wide SCSI buses are 16 bits wide and can have a maximum of 15 SCSI devices (targets) attached. The SCSI 3 draft standard allows a large number of ids to be present on a SCSI bus.
Each SCSI device can contain multiple Logical Unit Numbers (LUNs).
Prerequisite:
Before you are going for installation of iSCSI you must decide which drive or partition you need to export over network. It could be normal partition or LVM. In our scenario we are exporting Logical Volume. If you don’t know how to create LVM please refer How to configure LVM. If you don’t know how to create partition please refer How to create partition. In our scenario we are using we are using LVM because it is easy to extend its capacity when it’s needed. The logical drive name is: /dev/TestVolGrp/TVG_test .
How to install iSCSI on RHEL/CentOS linux:
On Server :
yum install scsi-target-utils
How to install iSCSI on Ubuntu/debian linux:
sudo apt-get install iscsitarget
tgt-admin uses /etc/tgt/targets.conf to initialize tgtd configuration, by default. Its layout uses a HTML-like structure, with a hierarchy of nested tags to define targets and LUNs.
Edit /etc/tgt/targets.conf
# vi /etc/tgt/targets.conf
Add following lines at the end of configuration file, make sure you replace /dev/TestVolGrp/TVG_test with your LV or partition.
<target iqn.2016-02.testlab.example:node1.target1> backing-store /dev/TestVolGrp/TVG_test </target>
Now start the tgtd service
# service tgtd start
Enable it on bootup:
# chkconfig tgtd on
Make sure port 3260 TCP/UDP and port 860 TCP/UDP are open in your firewall.
tgt-admin is a utility which allows a persistent configuration of targets and luns. It uses tgtadm commands to create, delete and show targets. -s options will show all the targets.
tgt-admin -s
It will dump something like below:
Target 1: iqn.2016-02.testlab.example:node1.target1 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, Block size: 1 Online: Yes Removable media: No Prevent removal: No Readonly: No Backing store type: null Backing store path: None Backing store flags: LUN: 1 Type: disk SCSI ID: IET 00010001 SCSI SN: beaf11 Size: 105 MB, Block size: 512 Online: Yes Removable media: No Prevent removal: No Readonly: No Backing store type: rdwr Backing store path: /dev/TestVolGrp/TVG_test Backing store flags: Account information: ACL information: ALL
How to map iSCSI LUN on client side:
Ubuntu/Debian :
sudo apt-get install open-iscsi
RHEL/CentOS
yum install iscsi-initiator-utils
Once you install iscsi client. The iscsiadm utility is a command-line tool allowing discovery and login to iSCSI targets, as well as access and management of the open-iscsi database. Use following command to discover the available LUN’s:
# iscsiadm -m discovery -t sendtargets -p 10.192.8.170
-m option is used to specify the mode. option must be one of discoverydb, node, fw, host iface or session. -t stands for type, type must be sendtargets (or abbreviated as st), slp, isns or fw. Currently only sendtargets, fw, and iSNS is supported. -p stands for portal, Use target portal with ip-address ip and port. If port is not passed in the default port value is 3260. Hostnames can also be used for the ip argument. -p option is only valid for discovery, or for node operations with the new operator. This should be used along with –target in node mode. The above command will print out-put something like below:
10.192.8.170:3260,1 iqn.2016-02.testlab.example:node1.target1
Now login/map to the specified target. -l option is used to login to specified target and -T to specify target. -m ‘node’ option will print all of their respective records.
# iscsiadm -m node -T iqn.2016-02.testlab.example:graphite.target1 -p 10.192.8.170 -l
Once you are successfully logged in it will print message like below:
Logging in to [iface: default, target: iqn.2016-02.testlab.example:node1.target1, portal: 10.192.8.170,3260] (multiple) Login to [iface: default, target: iqn.2016-02.testlab.example:node1.target1, portal: 10.192.8.170,3260] successful.
In /var/log/messages or in ubuntu /var/log/syslog it will log like this:
Jan 31 23:50:06 shree iscsid: Connection1:0 to [target: iqn.2016-02.testlab.example:node1.target1, portal: 10.192.8.170,3260] through [iface: default] is operational now
Once you done login now hit the fdisk -l command, it will print newly added target as local disk.
# fdisk -l
Disk /dev/sdb: 104 MB, 104857600 bytes 4 heads, 50 sectors/track, 1024 cylinders, total 204800 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
Now create new partition and format it with desired fs type. and mount it. If you don’t know how to create partition please refer how to create partition. If you don’t know what is file system and how to format it please refer what is file system.
mkfs.ext4 /dev/sdb
Now mount it:
mount -t ext4 /dev/sdb /share
How to mount iSCSI drive on windows :
- Open iSCSI Initiator in Windows under Control Panel > Administrative tools. Go to Discovery tab and click on Discover Portal. Enter the IP Address or the DNS Name of the server, which is hosting the iSCSI Target, then click on OK. Once it done.
- Open Computer Management under Control Panel > Administrative tools.
- Select Disk Management on the left panel. Right click on the iSCSI Target (Disk1) and choose Online.
- Right click on the iSCSI Target (Disk1) again and choose Initialize Disk.
- A prompt will be displayed to initialize the newly added virtual drive. Please select a partition style most appropriate for the disk to be used then click on OK.
- After the disk has been initialized, format the new partition with desired table.
How to unmount iSCSI targets on the client:
First of all unmount all the mount points associated with iSCSI Target and use below command :
# iscsiadm -m node -T iqn.2016-02.testlab.example:graphite.target1 -p 10.192.8.170 -u
-u option is used to logout for a specified record.
MOST COMMENTED
Uncategorized
Ubuntu 16.04 No desktop only shows background wallpaper
Administration / DNS / Linux
Dig command examples
Virtualization
OpenVz(Kernel Base Open source Virtulization)
Uncategorized
Install Ansible on Linux
Puppet
Configuring puppet4 server agent and puppetdb on ubuntu16.04
Database
Installing postgresql on ubuntu 16.04
Puppet
opensource puppet4 installation on ubuntu16.04