Step1.Discover lun on rhel2
[root@rhel2 ~]# iscsiadm -m discovery -t sendtargets -p 172.31.8.245 172.31.8.245:3260,1 iqn.2003-01.org.linux-iscsi.rhel1.x8664:sn.2b9c39390493 [root@rhel2 ~]#
In the above command we have used the ip address “172.31.8.245” which is ip of the server rhel1. We are able to see the server iqn number “iqn.2003-01.org.linux-iscsi.rhel1.x8664:sn.2b9c39390493” in the output means our configuration is Ok.
Step2. Check the current disks
Check the present disks attached at the client side using fdisk command:
[root@rhel2 ~]# fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: gpt # Start End Size Type Name 1 2048 4095 1M BIOS boot parti 2 4096 20971486 10G Microsoft basic
Step 3. Map lun0
Now map lun0 using the iqn number of the server taken from discovery step 1 command.
[root@rhel2 ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.rhel1.x8664:sn.2b9c39390493 -p 172.31.8.245 -l Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.rhel1.x8664:sn.2b9c39390493, portal: 172.31.8.245,3260] (multiple) Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.rhel1.x8664:sn.2b9c39390493, portal: 172.31.8.245,3260] successful. [root@rhel2 ~]#
Step 4.Recheck the disk attached.
Recheck the disks using fdisk command:
[root@rhel2 ~]# fdisk -l WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion. Disk /dev/xvda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: gpt # Start End Size Type Name 1 2048 4095 1M BIOS boot parti 2 4096 20971486 10G Microsoft basic Disk /dev/sda: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 131072 bytes
In the above output we can see new 2Gb disk /dev/sda which is presented using iscsi. To reconfirm the storage details use below commands:
[root@rhel2 ~]# cat /proc/scsi/scsi Attached devices: Host: scsi2 Channel: 00 Id: 00 Lun: 00 Vendor: LIO-ORG Model: mytestlun Rev: 4.0 Type: Direct-Access ANSI SCSI revision: 05 [root@rhel2 ~]#
In the above output you can see model as mytestlun which we have given during the iscsi target configuration and also in the dmesg output you can able to see below output.
[root@rhel2 ~]# dmesg | grep -i "attached " [ 2659.288073] scsi 2:0:0:0: Attached scsi generic sg0 type 0 [ 2659.322323] sd 2:0:0:0: [sda] Attached SCSI disk [root@rhel2 ~]#
This way we have successfully setup linux iSCSI target initiator on RHEL7.
Now you can configure LVM using the disk /dev/sda.
Leave a Reply