Installation guide

Chapter 24. Using shared storage with virtual disk images
This chapter covers the use of shared and network storage devices for virtual disks.
24.1. Using iSCSI for st oring virt ual disk images
This section demonstrates how to set up an iSCSI target on Red Hat Enterprise Linux and how to
configure iSCSI on a libvirt KVM host using virsh, and finally how to provision a guest on iSCSI
using virt-install.
Important
Setting up a Red Hat Enterprise Linux server as an iSCSI target is n o t recommended. The
example used in this section should not be used in production, and is provided as an
example which should only be referred to for basic shared storage testing and educational
purposes.
24 .1.1. How t o set up an iSCSI t arget on Red Hat Ent erprise Linux
1. In st all an d en ab le t h e iSCSI t arg et service
Install and enable the iSCSI target service with the following commands:
# yum install scsi-target-utils
# chkconfig tgtd on
# service tgtd start
Important
The scsi-target-utils package required for this example is provided only in the
Cluster Storage add-on for Red Hat Enterprise Linux 5, and may not be available for
your system. Contact your support agent to activate this add-on if you are currently
unable to install this package.
2. Allo cat e st orag e f o r t h e LUNs
The iSCSI target service is not dependent on a particular type of exported LUN. The LUNs can
be plain files, LVM volumes, or block devices. There is however a performance overhead if
using the LVM and/or file system layers as compared to block devices. The guest providing
the iSCSI service in this example has no spare block or LVM devices, so raw files will be used.
The following commands demonstrate the creation of two LUNs; one is 10GB (sparse file), the
other is 500MB (fully-allocated). Be aware that your environment will be different and this is
provided only as an example:
# mkdir -p /var/lib/tgtd/kvmguest
# dd if=/dev/zero of=/var/lib/tgtd/kvmguest/rhelx86_64.img bs=1M seek=10240
count=0
# dd if=/dev/zero of=/var/lib/tgtd/kvmguest/shareddata.img bs=1M count=512
# restorecon -R /var/lib/tgtd
Chapt er 2 4 . Using shared st orag e wit h virt ual disk images
24 9