004. Configure iSCSI Initiator In Linux

Introduction

Open-iSCSI is an open source implementation of iscsi in linux operating system.
Here I will show how to configure a simple iscsi initiator on a linux server.

Tested On

OS: CentOS 6.3 i386
open-iscsi version: 2.0-872
Hardware: Virtual Machine (VirtualBox 4.1.22)

Prerequisite

In order to configure iscsi initiator you need an iscsi target device that will provide a disk for your server.
You can use the following guide to create an iscsi target using linux

Procedure

  • Install open-scsi software
yum install iscsi-initiator-utils lsscsi -y
  • Discover luns on iscsi target server
iscsiadm --mode discovery -t st -p target_srv
  • Configure new lun
iscsiadm --mode discovery -t st -p target_srv --login
  • Check your new scsi disk device using fdisk
fdisk -l
  • Create new partition on your new disk and format it
fidsk /dev/sdc
n
p
1

wr
mkfs.ext4 /dev/sdc1
  • Configure your new created filesystem to mount at boot. Do not use the device name (/dev/sdc1) in /etc/fstab because it may not be persistent across reboots
mkdir /iscsi
vi /etc/fstab
...
/dev/disk/by-id/scsi-1IET_00010001-part1        /iscsi  ext4    defaults 0 0
...
  • Mount the new created file system
mount /iscsi

Useful Commands

  • Show active sessions
iscsiadm -m session
iscsiadm -m session -P 3
  • Check node configuration
iscsiadm -m node -p target_srv
  • Change device startup from automatic to manual
iscsiadm -m node -p target_srv -o update -n node.startup -v automatic

Remove iscsi device

First make sure the device is not being used and remove any reference to it

  • Logout from a configured iscsi device
iscsiadm --mode node --targetname iqn.2012-10.com.nachum234:server.target1 --portal target_srv --logout
  • Delete a configured iscsi device
iscsiadm -m discovery -t  send_targets -p target_srv -o delete

003. Create iSCSI Target in Linux

Introduction

tgt is scsi target framework for linux. Using tgt you can configure SCSI targets driver like iscsi, fcp, iSER and more.

Here I will show how to configure a simple iscsi target on a linux server.

Tested On

OS: CentOS 6.3 i386
tgtd version: 1.0.4
Hardware: Virtual Machine (VirtualBox 4.1.22)

Procedure

  • Install tgt software
yum install scsi-target-utils -y
  • Configure a new target device in /etc/tgt/targets.conf
vi /etc/tgt/targets.conf
<target iqn.2012-10.com.nachum234:server.target1>
    backing-store /dev/sdb2
</target>
  • Restart tgtd daemon and configure it to boot at start up
service tgtd start
chkconfig tgtd on
  • Show your configured targets
tgt-admin -s

Please visit http://stgt.sourceforge.net/ for more information about linux tgt configuration and usage.

001. Configure Time Zone Using Shell Commands

OS: CentOS 6.2
Hardware: Virtual Machine (VirtualBox 4.1.8)

Configure Time Zone Using Shell Commands

  • Configure /etc/sysconfig/clock file to the requested time zone, all time zones can be find in /usr/share/zoneinfo
vi /etc/sysconfig/clock
ZONE="Israel"
  • Remove existing localtime file and creating new localtime symbolic link to the requested time zone file
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Israel /etc/localtime

For more information on time, date and time zone configuration please check the following: http://www.vanemery.com/Linux/RH-Linux-Time.html