The virtual disk of a virtual machine is the HDD image. Virtual disks are stored in a local or network storage. An iSCSI storage is a network storage that uses the network access protocol (iSCSI) to file systems. This article describes how to configure an iSCSI-storage. For more information please refer to the article Network storages.

Preliminary steps


  • VMmanager manages the server-storage through ssh;
  • VMmanager uses open-iscsi; all required packages should be installed, and the tgtd service must be up and running. Make sure tgtd starts automatically upon restart.

Install open-iscsi and set up the autostart for tgtd:

yum install epel-release
yum install scsi-target-utils
service tgtd start
chkconfig tgtd on
BASH

Add iptables rules if needed:

iptables -I INPUT 1 -p tcp --dport 3260 -j ACCEPT
service iptables save 
BASH

If the cluster nodes are accessible through internal network interfaces, then the iSCSI-server must be also accessible through internal interfaces. This allows open-iscsi to add добавлял разрешения для узлов кластера for cluster nodes correctly. 

After you have configured the storage server, go to  Storage templates and add an iSCSI storage. More information can be found in the article How to connect a storage.

Principles of operation


Creating a storage

While creating a storage in VMmanager:

  • a target named iqn.YYYY-MM.<hostname-reverse>.<storage>_ID (where ID - unique identifier) is created on the server running iSCSI ;
  • The <storage>_ID pool is created in libvirt. Libvirt imports the target and all LUNs from that target.

Thus, the storage is a set of pools with different IDs.

Example: let's create an iscsi-storage named NetStorage.

  • NetStorage_001 will be created in libvirt
  • The iqn.2013-04.org.our-dc.stor1.NetStorage_001 target will be created on the server running iscsi
  • The target will be added to the /etc/tgt/vmmgr/<target_name>.conf file, therefore the targets won't be deleted upon restart. For each target separate file configuration will be created in the directory /etc/tgt/vmmgr/

The above procedure enables VMmanager to create more than 256 virtual disks on one storage. If you want to create more virtual disks, new targets NetStorage_002, NetStorage_003, etc. will be created.

Creating a virtual disk

In the iSCSI-storage disks are created as files in the directory specified by the iSCSITargetDir parameter in the VMmanager configuration file, by default in /iscsivolumes

Creation of a new virtual disk includes the following steps:

  • a file is created in the /iscsivolumes directory on the iSCSI-server. The file has the same name as the virtual disk.
  • VMmanager defines the ID of the target, where LUN will be created. If the target has more than 150 LUNs, a new iqn.YYYY-MM.<hostname-reverse> target will be created .<storage>_ID, where the ID is greater by 1.
  • A new libvirt pool named <storage>_ID will be created on the cluster nodes.
  • A new LUN will be created in that target and added to the /etc/tgt/vmmgrtargets.conf file. Its id will be kept in the database.
  • Information about the libvirt pools will be updated on all the cluster nodes (run the virsh pool-refresh <storage>_ID command)

Once completed, the newly created virtual disk will be available on all the cluster nodes. You can locate the unit:0:0:LUN_ID virtual disk in the <storage>_ID pool.