Installation guide

Chapter 26. Storage pools
224
Procedure 26.3. Creating an iSCSI target
1. Install the required packages
Install the scsi-target-utils package and all dependencies
# yum install scsi-target-utils
2. Start the tgtd service
The tgtd service hosts SCSI targets and uses the iSCSI protocol to host targets. Start the tgtd
service and make the service persistent after restarting with the chkconfig command.
# service tgtd start
# chkconfig tgtd on
3. Optional: Create LVM volumes
LVM volumes are useful for iSCSI backing images. LVM snapshots and resizing can be beneficial
for virtualized guests. This example creates an LVM image named virtimage1 on a new volume
group named virtstore on a RAID5 array for hosting virtualized guests with iSCSI.
a. Create the RAID array
Creating software RAID5 arrays is covered by the Red Hat Enterprise Linux Deployment
Guide.
b. Create the LVM volume group
Create a volume group named virtstore with the vgcreate command.
# vgcreate virtstore /dev/md1
c. Create a LVM logical volume
Create a logical volume group named virtimage1 on the virtstore volume group with a
size of 20GB using the lvcreate command.
# lvcreate --size 20G -n virtimage1
virtstore
The new logical volume, virtimage1, is ready to use for iSCSI.
4. Optional: Create file-based images
File-based storage is sufficient for testing but is not recommended for production environments
or any significant I/O activity. This optional procedure creates a file based imaged named
virtimage2.img for an iSCSI target.
a. Create a new directory for the image
Create a new directory to store the image. The directory must have the correct SELinux
contexts.
# mkdir -p /var/lib/tgtd/virtualization
b. Create the image file
Create an image named virtimage2.img with a size of 10GB.
# dd if=/dev/zero of=/var/lib/tgtd/virtualization/virtimage2.img bs=1M seek=10000
count=0