Connect iSCSI LUNs to RHEL/CENTOS
This article will walk through attaching an iSCSI LUN to RHEL/CentOS 7.
These instructions are only compatible with CentOS 7 and RHEL 7
Install the iSCSI libraries on the server:
yum -y install iscsi-initiator-utils device-mapper-multipath lldpad
Start iSCSI Services:
Once all of the pre-requisite packages have been installed, all of the iscsi services need to be started and configured to start on boot.
systemctl start iscsi; systemctl start iscsid ; systemctl start multipathd ; systemctl enable iscsi ; systemctl enable iscsid ; systemctl enable multipathd ;
Ensure that either the chassis or switch port that the server is connected to is set to the proper iSCSI VLAN or the interface will not be able to communicate with the iSCSI Target.
Adapter TYPE=Ethernet BOOTPROTO=none DEFROUTE=no IPV4_FAILURE_FATAL=no IPV6INIT=no IPV6_AUTOCONF=no IPV6_DEFROUTE=no IPV6_FAILURE_FATAL=no NAME=enp8s0 UUID=5e72182e-82ca-4072-a376-1645852871b4 DEVICE=enp8s0 ONBOOT=yes MTU=9000 DCB=on DCB_APP_FCOE=no DCB_APP_FCOE_ENABLE=no DCB_APP_ISCSI=yes DCB_APP_ISCSI_CFG=40 DCB_APP_ISCSI_ENABLE=yes DCB_APP_ISCSI_ADVERTISE=yes DCB_APP_ISCSI_WILLING=yes PEERDNS=yes PEERROUTES=yes IPV6_PEERDNS=no IPV6_PEERROUTES=no IPV6_PRIVACY=no IPADDR=184.108.40.206 NETMASK=255.255.0.0
Get Initiator Name:
Once the interfaces have been configured, we need the initiator name, which will be used on the iSCSI target, to allow access to the iSCSI resource.
Assuming that the server initiator has been granted access to the LUN on the target, performing a discovery should show the LUNs that have been assigned to the initiator.
iscsiadm -m discovery -t sendtargets -p 220.127.116.11
Use the commands below to show information about the LUNs that have been assigned to the initiator.
iscsiadm -m session -o show iscsiadm -m node -o show
Login to the Target:
Logging onto the target should map the LUNs to the server. Once logged in, the LUNs should be visable on the server.
iscsiadm -m node --login
Prepare the LUNs
Fdisk the LUNs as you would a standard disk
Mount the LUNs
Edit the /etc/fstab file and add an entry similar to the following: * In this example the LUN is being mounted to /var/lib/docker, before mounting ensure that the mount target directory exists.
/dev/sdb1 /var/lib/docker/ ext4 defaults,_netdev 0 0