Chapter 27. Set up an iSCSI Target and Initiator

download PDF


When using the hal daemon with a large number of iSCSI LUNs, over several thousand, the --child-timeout option should be used in order to avoid boot failures. The --child-timeout option sets the number of seconds to wait for all disk probes to run. For example, to force the hal daemon to wait 10 minutes and 30 seconds, the option would read --child-timeout=630. The default time is 250 seconds. While this means the hal daemon will take longer to start, it will give enough time for all disk devices to be recognized and avoid boot failures.
The reason for this work around is because in 2003 when the hal daemon was created, it was unusual to have more than a dozen iSCSI disks. It is for this reason, the hal daemon has been removed in Red Hat Enterprise Linux 7 and replaced with udisks.
For more information, see the following Red Hat Knowledgebase solution: haldaemon fails to start on system with a large number of disks in RHEL 5 and RHEL 6

27.1. iSCSI Target Creation

An iSCSI target can be a dedicated physical device in a network, or it can be an iSCSI software-configured logical device on a networked storage server. The target is the end point in SCSI bus communication. Storage on the target, accessed by an initiator, is defined by LUNs.

Procedure 27.1. Create an iSCSI Target

  1. Install scsi-target-utils.
    ~]# yum install scsi-target-utils
  2. Open port 3260 in the firewall.
    ~]# iptables -I INPUT -p tcp -m tcp --dport 3260 -j ACCEPT
    ~]# service iptables save
  3. Start and enable the target service.
    ~]# service tgtd start
    ~]# chkconfig tgtd on
  4. Allocate storage for the LUNs. In this example a new partition is being created for block storage.
    ~]# fdisk /dev/vdb
    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 0x43eb8efd.
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): *Enter*
    Using default response p
    Partition number (1-4, default 1): *Enter*
    First sector (2048-2097151, default 2048): *Enter*
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +250M
    Partition 1 of type Linux and of size 250 MiB is set
    Command (m for help): w
    The partition table has been altered!
    Calling ioctl() to re-read partition table.
    Syncing disks.
  5. Edit the /etc/tgt/targets.conf file to create the target.
    ~]# cat /etc/tgt/targets.conf
    default-driver iscsi
    	backing-store /dev/vdb1
    In the above example a simple target containing one backing store and one allowed initiator has been created. It must be named with an iqn name in the format of The backing store is the device the storage is located on. The initiator-address is the IP address of the initiator to access the storage.
  6. Restart the target service.
    ~]# service tgtd restart
    Stopping SCSI target daemon:     [ OK ]
    Starting SCSI target daemon:     [ OK ]
  7. Check the configuration.
    ~]# tgt-admin --show
    Target 1: server
    	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: 2147 MB, Block size: 512
    			Online: Yes
    			Removable media: No
    			Prevent removal: No
    			Readonly: No
    			Backing store type: rdwr
    			Backing store path: /dev/vdb1
    			Backing store flags:
    	Account information:
    	ACL information:
Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.