iSCSI, which stands for Internet Small Computer System Interface, works on top of the Transport Control Protocol (TCP) and allows the SCSI command to be sent end-to-end over local-area networks (LANs), wide-area networks (WANs) or the Internet.
- Create one LVM
- Convert that LVM into LUN using iSCSI Software
- Map Converted LUN to initiator and use it as a local HDD to initiator
Creating LVM
[root@server4 ~]# fdisk /dev/vdbWelcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xab08db42.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): Hit Enter
Using default response p
Partition number (1-4, default 1): Hit Enter
First sector (2048-20971519, default 2048):Hit Enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +5G
Partition 1 of type Linux and of size 5 GiB is set
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@server4 ~]# partprobe /dev/vdb
[root@server4 ~]# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created
[root@server4 ~]# vgcreate vgiscsi /dev/vdb1
Volume group "vgiscsi" successfully created
[root@server4 ~]# lvcreate -l 100%FREE -n lviscsi vgiscsi
Logical volume "lviscsi" created
[root@server4 ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lviscsi vgiscsi -wi-a----- 5.00g
[root@server4 ~]# yum install targetcli*
[root@server4 ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> ls
o- / ......................................................................................................................... [...]
o- backstores ........................................ [...]
| o- block ........................... [Storage Objects: 0]
| o- fileio ............................... [Storage Objects: 0]
| o- pscsi ............................... [Storage Objects: 0]
| o- ramdisk ............................ [Storage Objects: 0]
o- iscsi ........................................ [Targets: 0]
o- loopback ..................................... [Targets: 0]
/> /backstores/block create iscsilun /dev/vgiscsi/lviscsi
Created block storage object iscsilun using /dev/vgiscsi/lviscsi.
/> ls
o- / ...................................................... [...]
o- backstores ........................................... [...]
| o- block ............................... [Storage Objects: 1]
| | o- iscsilun ...[/dev/vgiscsi/lviscsi (5.0GiB) write-thru deactivated]
| o- fileio ................................. [Storage Objects: 0]
| o- pscsi ............................... [Storage Objects: 0]
| o- ramdisk ............................ [Storage Objects: 0]
o- iscsi ........................................ [Targets: 0]
o- loopback ..................................... [Targets: 0]
/> /iscsi create iqn.2017-03.com.arkit:server4
Created target iqn.2017-03.com.arkit:server4.
Created TPG 1.
/> ls
o- / ..................................................... [...]
o- backstores .......................................... [...]
| o- block .............................. [Storage Objects: 1]
| | o- iscsilun .......... [/dev/vgiscsi/lviscsi (5.0GiB) write-thru deactivated]
| o- fileio ............................. [Storage Objects: 0]
| o- pscsi .............................. [Storage Objects: 0]
| o- ramdisk ............................ [Storage Objects: 0]
o- iscsi ........................................ [Targets: 1]
| o- iqn.2017-03.com.arkit:server4 ................. [TPGs: 1]
| o- tpg1 ........................... [no-gen-acls, no-auth]
| o- acls ...................................... [ACLs: 0]
| o- luns ...................................... [LUNs: 0]
| o- portals ................................ [Portals: 0]
o- loopback ...................................... [Targets: 0]
GO TO Client side and collect the iqn number
[root@desktop4 ~]# yum install iscsi*Loaded plugins: langpacks
rhel_dvd | 4.1 kB 00:00:00
(1/2): rhel_dvd/group_gz | 134 kB 00:00:00
(2/2): rhel_dvd/primary_db | 3.4 MB 00:00:00
Package iscsi-initiator-utils-6.2.0.873-21.el7.x86_64 already installed and latest version
Package iscsi-initiator-utils-iscsiuio-6.2.0.873-21.el7.x86_64 already installed and latest version
Nothing to do
[root@desktop4 ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:9e96ff23da37
[root@desktop4 ~]# systemctl enable iscsid.service
ln -s '/usr/lib/systemd/system/iscsid.service' '/etc/systemd/system/multi-user.target.wants/iscsid.service'
[root@desktop4 ~]# systemctl start iscsid.service
Come Back to the Server and Map LUN to Initiator
/> /iscsi/iqn.2017-03.com.arkit:server4/tpg1/acls create iqn.1994-05.com.redhat:9e96ff23da37
Created Node ACL for iqn.1994-05.com.redhat:9e96ff23da37
/> iscsi/iqn.2017-03.com.arkit:server4/tpg1/luns create /backstores/block/iscsilun
Created LUN 0.
Created LUN 0->0 mapping in node ACL iqn.1994-05.com.redhat:9e96ff23da37
/> /iscsi/iqn.2017-03.com.arkit:server4/tpg1/portals create 172.25.4.11
Using default IP port 3260
Created network portal 172.25.4.11:3260.
/> saveconfig
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
Press CTRL + D
[root@server4 ~]# firewall-cmd --permanent --add-port=3260/tcp
success
[root@server4 ~]# firewall-cmd --reload
success
Go To Client and Connect the Mapped LUN
[root@desktop4 ~]# iscsiadm -m discovery -t st -p 172.25.4.11172.25.4.11:3260,1 iqn.2017-03.com.arkit:server4
[root@desktop4 ~]# iscsiadm -m node -T iqn.2017-03.com.arkit:server4 -p 172.25.4.11 -l
Logging in to [iface: default, target: iqn.2017-03.com.arkit:server4, portal: 172.25.4.11,3260] (multiple)
Login to [iface: default, target: iqn.2017-03.com.arkit:server4, portal: 172.25.4.11,3260] successful.
[root@desktop4 ~]# fdisk -l /dev/sda
Disk /dev/sda: 5364 MB, 5364514816 bytes, 10477568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
[root@desktop4 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x2e115ccc.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (8192-10477567, default 8192):
Using default value 8192
Last sector, +sectors or +size{K,M,G} (8192-10477567, default 10477567):
Using default value 10477567
Partition 1 of type Linux and of size 5 GiB is set
Command (m for help): p
Disk /dev/sda: 5364 MB, 5364514816 bytes, 10477568 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 4194304 bytes
Disk label type: dos
Disk identifier: 0x2e115ccc
Device Boot Start End Blocks Id System
/dev/sda1 8192 10477567 5234688 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): wq
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@desktop4 ~]# partprobe /dev/sda
[root@desktop4 ~]# mkfs.ext4 /dev/sda1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=1024 blocks
327680 inodes, 1308672 blocks
65433 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1340080128
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@desktop4 ~]# mkdir /ravi
[root@desktop4 ~]# vim /etc/fstab
[root@desktop4 ~]# cat /etc/fstab |grep sda
/dev/sda1 /ravi ext4 _netdev 0 0
[root@desktop4 ~]# mount -a
[root@desktop4 ~]# df -h |grep ravi
/dev/sda1 4.8G 20M 4.6G 1% /ravi
Enjoy................
Helped Very Much, thank you admin !!
ReplyDelete