.. _Accessing Virtuozzo Storage Clusters via iSCSI:

Accessing Virtuozzo Storage Clusters via iSCSI
----------------------------------------------

Virtuozzo Storage allows you to export cluster disk space outside Virtuozzo Storage bounds to operating systems and third-party virtualization solutions. Using dedicated ``vstorage-iscsi`` tools, you can export Virtuozzo Storage disk space as LUN block devices over iSCSI in a SAN-like manner.

In Virtuozzo Storage, you can create and run multiple iSCSI targets per Virtuozzo Storage cluster Node. In turn, each iSCSI target can have multiple LUNs (virtual disks). At any given moment, each iSCSI target runs on a single Hardware Node. Thanks to High Availability, if a Node fails, iSCSI targets hosted on it are moved to and relaunched on a healthy Node (for more details on High Availability, see the HA chapter in the Virtuozzo 7 User's Guide).

The figure below shows a typical network configured for exporting Virtuozzo Storage disk space over iSCSI.

.. image:: ../../../images/image006.png
        :align: center
	:class: align-center

In this example are three Virtuozzo Hardware Nodes working in a Virtuozzo Storage cluster. Two Nodes host one iSCSI target each while the third hosts two iSCSI targets. Each Node has a static or dynamic IP address assigned from the Storage BackNet (created along with the Virtuozzo Storage cluster) and the FrontNet. Each iSCSI target has a static IP address assigned from the FrontNet.

.. _Preparing to Work with Virtuozzo Storage iSCSI Targets:

Preparing to Work with Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On each Virtuozzo Hardware Node, where you need to create and run iSCSI targets, do the following:

1. Make sure the ``vstorage-iscsi`` and ``pstorage-scsi-target-utils`` packages are installed on the Hardware Node.

2. Make sure that the Hardware Node has access to the Virtuozzo Storage cluster as client and has an entry in ``/etc/fstab``. For more information, see :ref:`Setting Up Clients`.

3. Create a directory in the Virtuozzo Storage cluster where you will store iSCSI targets and their configuration. For example, ``/vstorage/stor1/iscsi``.

4. Set the ``ISCSI_ROOT`` variable in ``/etc/vstorage/iscsi/config`` to the directory from the previous step. For example:
   ISCSI_ROOT=/vstorage/stor1/iscsi

5. Enable High Availability support for the Hardware Node. For information on how to do it, see the *Virtuozzo 7 User's Guide*.

You are now ready to create and run iSCSI targets in your Virtuozzo Storage cluster.

.. _Creating and Running Virtuozzo Storage iSCSI Targets:

Creating and Running Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note::

   1. Each iSCSI target must be assigned at least one unique IP address from frontnet's static pool.

   2. The name of each iSCSI target must be unique in the Virtuozzo Storage cluster.

   3. Virtuozzo Storage iSCSI targets support persistent reservations to allow iSCSI initiators obtain exclusive access to the specified target's LUNs.

To create and start a target ``test1`` with the size of 100 GB, the LUN of 1, and the IP address of 192.168.10.100, execute the following commands:

::

    # vstorage-iscsi create -n test1 -a 192.168.10.100
    IQN: iqn.2014-04.com.vstorage:test1
    # vstorage-iscsi lun-add -t iqn.2014-04.com.vstorage:test1 -l 1 -s 100G
    # vstorage-iscsi start -t iqn.2014-04.com.vstorage:test1

.. note::

   1. If you need to change target's IP address, stop the target as described in :ref:`Stopping Virtuozzo Storage iSCSI Targets`, then run the command ``vstorage-iscsi set -t <target_name> -a <new_IP_address>``.

   2. If you need to increase the size of a LUN, stop the target as described in :ref:`Stopping Virtuozzo Storage iSCSI Targets`, then run the command ``vstorage-iscsi lun-grow -t <target_name> -l <lun_ID> -s <new_size>``.

To check that the target is up, run the ``vstorage-iscsi list`` command with the target's name as the option. For example:

::

    # vstorage-iscsi list -t iqn.2014-04.com.vstorage:test1
    Target iqn.2014-04.com.vstorage:test1:
     Portals:     192.168.10.100
     Status:      running
     Registered:  yes
     Host:        fefacc38a2f140ca
     LUN:   1, Size:  102400M, Used:     1M, Online: Yes

For information about the command output, see :ref:`Listing Virtuozzo Storage iSCSI Targets`.

iSCSI initiators can now access the target ``iqn.2014-04.com.vstorage:test1`` via the portal 192.168.10.100.

**Performance Tips**

-  Spread iSCSI targets evenly across Hardware Nodes in the cluster. For example, 10 Hardware Nodes with 1 iSCSI target per each will perform better than a single Hardware Node with 10 iSCSI targets on it.

-  More LUNs per fewer iSCSI targets will perform better than fewer LUNs per more iSCSI targets.

.. _Listing Virtuozzo Storage iSCSI Targets:

Listing Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using the ``vstorage-iscsi list`` command, you can list all iSCSI targets registered on a Virtuozzo Storage Node or display detailed information about a specific iSCSI target on a Virtuozzo Storage Node.

To list all iSCSI targets registered on a Virtuozzo Storage Node, run the command as follows:

::

    # vstorage-iscsi list
    IQN                             STATUS  LUNs HOST             PORTAL(s)    
    iqn.2014-04.com.vstorage:test1  running 1    fefacc38a2f140ca 192.168.10.100
    iqn.2014-04.com.vstorage:test2  running 1    fefacc38a2f140ca 192.168.10.101
    iqn.2014-04.com.vstorage:test3  stopped 1    fefacc38a2f140ca 192.168.10.102
    iqn.2014-04.com.vstorage:test4  stopped 0    fefacc38a2f140ca 192.168.10.103

To display detailed information about an iSCSI target registered on a Virtuozzo Storage Node, run the ``vstorage-iscsi list`` command with the target's name as the option. For example:

::

    # vstorage-iscsi list -t iqn.2014-04.com.vstorage:test1
    Target iqn.2014-04.com.vstorage:test1:
     Portals:     192.168.10.100
     Status:      running
     Registered:  yes
     Host:        fefacc38a2f140ca
     LUN:   1, Size:  102400M, Used:     1M, Online: Yes

The command outputs above show the following data:

+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Item                           | Description                                                                                                                                                                               |
+================================+===========================================================================================================================================================================================+
| Target                         | Unique alphanumeric name of the iSCSI target.                                                                                                                                             |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Portals                        | Target's IP address(es).                                                                                                                                                                  |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Status                         | Target's current state.                                                                                                                                                                   |
|                                |                                                                                                                                                                                           |
|                                | -  running: target is running and ready for use (for local targets).                                                                                                                      |
|                                |                                                                                                                                                                                           |
|                                | -  stopped: target is stopped (for local targets).                                                                                                                                        |
|                                |                                                                                                                                                                                           |
|                                | -  service failed: the iSCSI service is down (for local targets).                                                                                                                         |
|                                |                                                                                                                                                                                           |
|                                | -  remote: target is registered on a different Node.                                                                                                                                      |
|                                |                                                                                                                                                                                           |
|                                | -  unregistered: target is not registered on any Node in the Virtuozzo Storage cluster.                                                                                                   |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Registered                     | Whether or not the target is registered on the host which ID is shown in the Host entry.                                                                                                  |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Host                           | Virtuozzo Storage Hardware Node ID.                                                                                                                                                       |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| LUN                            | Virtual disk's integer number within the target.                                                                                                                                          |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Size                           | Virtual disk's logical size (16 TB maximum).                                                                                                                                              |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Used                           | Virtual disk's physical size. The physical size can be smaller than logical due to the expanding format of the virtual disk (for more information, see the *Virtuozzo 7 User's Guide*).   |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Online                         | -  Yes: the LUN is visible to and can be mounted by iSCSI initiators.                                                                                                                     |
|                                |                                                                                                                                                                                           |
|                                | -  No: the LUN is invisible to and cannot be mounted by iSCSI initiators.                                                                                                                 |
+--------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

.. _Transferring Virtuozzo Storage iSCSI Targets Between Virtuozzo Storage Nodes:

Transferring Virtuozzo Storage iSCSI Targets Between Virtuozzo Storage Nodes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can transfer stopped iSCSI targets between Virtuozzo Storage Nodes. After the transfer, you will be able to start and manage the iSCSI target on the destination Node. On the source Node, you will only be able to delete the transferred target with the ``--force`` option (for more details, see :ref:`Deleting Virtuozzo Storage iSCSI Targets`).

To transfer an iSCSI target, do the following:

1. Make sure the target is stopped. For more details, see :ref:`Stopping Virtuozzo Storage iSCSI Targets`.

2. Unregister the target on its current Node with the ``vstorage-iscsi unregister`` command. For example:

   ::

       # vstorage-iscsi unregister -t iqn.2014-04.com.vstorage:test1

3. Register the target on the new Node with the ``vstorage-iscsi register`` command. For example:

   ::

       # vstorage-iscsi register -t iqn.2014-04.com.vstorage:test1

.. _Stopping Virtuozzo Storage iSCSI Targets:

Stopping Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To stop a Virtuozzo Storage iSCSI target to which no initiators are connected, use the ``vstorage-iscsi stop`` command. For example, for the target ``iqn.2014-04.com.vstorage:test1``:

::

    # vstorage-iscsi stop -t iqn.2014-04.com.vstorage:test1

If one or more iSCSI initiators are still connected to the target, you will be informed as follows:

::

    # vstorage-iscsi stop -t iqn.2014-04.com.vstorage:test1
    initiators still connected
    Initiator:   iqn.1994-05.com.redhat:c678b9f6f0 (192.168.30.100)
    Unable stop target iqn.2014-04.com.vstorage:test1

In this case, disconnect the iSCSI initiator according to the product manual and run the ``vstorage-iscsi stop`` command again.

To forcibly stop a target to which one or more initiators are still connected, add the ``-f`` option to the command above. For example:

::

    # vstorage-iscsi stop -t iqn.2014-04.com.vstorage:test1 -f

Breaking the iSCSI connection in such a way may result in I/O errors on the iSCSI initiator's side.

.. _Deleting Virtuozzo Storage iSCSI Targets:

Deleting Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can delete Virtuozzo Storage iSCSI targets with the vstorage-iscsi delete command. Deleting a Virtuozzo Storage iSCSI target, you will also delete all the LUNs within it.

To delete a Virtuozzo Storage iSCSI target, do the following:

1. Make sure the target is stopped (for more details, see :ref:`Stopping Virtuozzo Storage iSCSI Targets`).

2. Run the ``vstorage-iscsi delete`` command with the target name as the option. For example:

   ::

       # vstorage-iscsi delete -t iqn.2014-04.com.vstorage:test1

To delete a stopped iSCSI target registered on a different host, add the ``--force`` option to the ``vstorage-iscsi delete`` command. For example:

   ::

       # vstorage-iscsi delete -t iqn.2014-04.com.vstorage:test1 --force

.. _Accessing Virtuozzo Storage iSCSI Targets from Operating Systems and Third-Party Virtualization Solutions:

Accessing Virtuozzo Storage iSCSI Targets from Operating Systems and Third-Party Virtualization Solutions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This section describes ways to attach Virtuozzo Storage iSCSI targets to a number of operating systems and third-party virtualization solutions.

.. _Accessing Virtuozzo Storage iSCSI Targets from CentOS 6.5:

Accessing Virtuozzo Storage iSCSI Targets from CentOS 6.5
*********************************************************

1. Make sure that the ``iscsi-initiator-utils`` package is installed.

2. Discover the required target by its IP address. For example:

   ::

       # iscsiadm --mode discovery --type sendtargets --portal 192.168.10.100

3. Restart the ``iscsid`` service to rescan for newly added drives:

   ::

       # service iscsi restart

To check that the new drive has appeared in the system, use ``fdisk``, ``parted`` or similar tools.

For more information, see the `Red Hat Enterprise Linux Storage Administration Guide <https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-iscsi.html>`_.

.. _Accessing Virtuozzo Storage iSCSI Targets from Microsoft Windows Server 2012 R2:

Accessing Virtuozzo Storage iSCSI Targets from Microsoft Windows Server 2012 R2
*******************************************************************************

1. In the **Server Manager Dashboard**, click the **Tools** menu in the toolbar and select **iSCSI Initiator**.

   .. image:: ../../../images/image007.jpg
        :align: center
	:class: align-center

2. In the **iSCSI Initiator Properties**, switch to the **Discovery** tab and click **Discover Portal...**.

   .. image:: ../../../images/image008.png
        :align: center
	:class: align-center

3. In the **Discover Target Portal** window, enter the portal IP address and click **OK**.

   .. image:: ../../../images/image009.png
        :align: center
	:class: align-center

   The newly added portal will appear in the **Target portals** section.

4. On the **iSCSI Initiator Properties** > **Targets** tab, select the new target in the **Discovered targets** section and click **Connect**.

   .. image:: ../../../images/image010.png
        :align: center
	:class: align-center

5. In the **Connect to Target** window, click **OK**.

   .. image:: ../../../images/image011.png
        :align: center
	:class: align-center

6. Target's **Inactive** status will change to **Connected**.

   .. image:: ../../../images/image012.png
        :align: center
	:class: align-center

7. The newly attached disk will appear in **Server Manager Dashboard** > **Computer Management** > **Storage** > **Disk Management**.

   .. image:: ../../../images/image013.png
        :align: center
	:class: align-center

8. Right-click the disk information section and select **Online**.

   .. image:: ../../../images/image014.png
        :align: center
	:class: align-center

   The disk status will change to **Online**.

9. Right-click the disk information section and select **Initialize Disk**.

   .. image:: ../../../images/image015.png
        :align: center
	:class: align-center

10. In the Initialize Disk window, click **OK**.

    .. image:: ../../../images/image016.png
        :align: center
	:class: align-center

11. Right-click the disk space section, select **New Simple Volume...**, and follow the wizard's instruction to format the new disk to NTFS.

    .. image:: ../../../images/image017.png
        :align: center
	:class: align-center

12. The disk state will change to **Healthy**.

    .. image:: ../../../images/image018.png
        :align: center
	:class: align-center

13. The new disk will appear in Windows Explorer.

    .. image:: ../../../images/image019.jpg
        :align: center
	:class: align-center

.. _Accessing Virtuozzo Storage iSCSI Targets from VMware ESXi:

Accessing Virtuozzo Storage iSCSI Targets from VMware ESXi
**********************************************************

1. In the **vSphere Client**, switch to the **Configuration** tab, and click **Storage Adapters** in the **Hardware** section.

2. If no software iSCSI adapters have been added, do so by right-clicking in the **Storage Adapters** section and selecting **Add Software iSCSI Adapter...**.

3. Open the software iSCSI adapter's properties, switch to the **Static Discovery** tab and click **Add...**.

4. In the **Add Static Target Server** window, enter the target's IP address and name.

5. Close the software iSCSI adapter's properties window and rescan the adapter as prompted.

6. The newly added iSCSI target will appear in the **Details** section of the software iSCSI adapter you have configured.

7. For more information, see the `VMware vSphere Storage Guide <http://pubs.vmware.com/vsphere-50/topic/com.vmware.ICbase/PDF/vsphere-esxi-vcenter-server-50-storage-guide.pdf>`_.

.. _Accessing Virtuozzo Storage iSCSI Targets from Citrix XenServer 6.2:

Accessing Virtuozzo Storage iSCSI Targets from Citrix XenServer 6.2
*******************************************************************

1. In XenCenter, switch to the **Storage** tab and click **New SR...**.

2. In the **New Storage Repository** window:

   1. In the **Type** section, select the **Software iSCSI** option,

   2. In the **Name** section, provide a name or leave the default,

   3. In the **Location** section, enter target's IP address in the **Target Host** field, click **Discover IQNs** and select the desired target, then click **Discover LUNs** and select the desired LUN.

3. Click **Finish** to format the disk.

The new storage repository will appear in XenCenter.

For more information, see XenCenter documentation at http://support.citrix.com/proddocs/topic/xencenter-62/xs-xc-storage.html.

.. _Accessing Virtuozzo Storage iSCSI Targets from Microsoft Hyper-V:

Accessing Virtuozzo Storage iSCSI Targets from Microsoft Hyper-V
****************************************************************

.. note:: Names of the targets to be mounted must not contain underscore characters.

1. Make sure that Microsoft iSCSI Initiator Service, ``MSiSCSI``, is running.

2. Discover a new target portal. For example, for the portal 192.168.10.100, run:
   
   ::

       PS C:\Users\Administrator>new-iscsitargetportal -targetportaladdress 192.168.10.100
       Initiator Instance Name  :
       Initiator Portal Address :
       IsDataDigest             : False
       IsHeaderDigest           : False
       TargetPortalAddress      : 192.168.10.100
       TargetPortalPortNumber   : 3260
       PSComputerName           :

3. Connect to the desired target. For example, for the target iqn.2014-03.com.vstorage:test1
   
   ::

       PS C:\Users\Administrator> connect-iscsitarget
       cmdlet Connect-IscsiTarget at command pipeline position 1
       Supply values for the following parameters:
       NodeAddress: iqn.2014-04.com.vstorage:test1
       AuthenticationType      : NONE
       InitiatorInstanceName   : ROOT\ISCSIPRT\0000_0
       InitiatorNodeAddress    : iqn.1991-05.com.microsoft:win-l2dj7g36n7e.sw.swsoft.com
       InitiatorPortalAddress  : 0.0.0.0
       InitiatorSideIdentifier : 400001370000
       IsConnected             : True
       IsDataDigest            : False
       IsDiscovered            : True
       IsHeaderDigest          : False
       IsPersistent            : False
       NumberOfConnections     : 1
       SessionIdentifier       : ffffe00000b5e020-4000013700000005
       TargetNodeAddress       : iqn.2014-04.com.vstorage:test1
       TargetSideIdentifier    : 0001
       PSComputerName          :

4. To check that the disk has been connected, run
   
   ::

       PS C:\Users\Administrator> get-disk
       Number Friendly Name                     OperationalStatus Total Size Partition Style
       ------ -------------                     ----------------- ---------- ---------------
       1      IET VIRTUAL-DISK SCSI Disk Device Offline           100 GB RAW
       <...>

You can now initialise the newly mounted disk for use in Microsoft Hyper-V.

For more information, see *iSCSI Cmdlets in Windows PowerShell* at http://technet.microsoft.com/en-us/library/hh826099.aspx.

.. _Configuring Multipath I/O for Virtuozzo Storage iSCSI Targets:

Configuring Multipath I/O for Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Multipath I/O is a technique called to increase fault tolerance and performance by establishing multiple paths to the same iSCSI target. The figure below shows a typical multipath-enabled network configured for exporting Virtuozzo Storage disk space over iSCSI.

.. image:: ../../../images/image020.jpg
        :align: center
	:class: align-center

In this example are three Virtuozzo Hardware Nodes working in a Virtuozzo Storage cluster. Two Nodes host one iSCSI target each while the third hosts two iSCSI targets. Each Hardware Node is assigned a static or dynamic IP address from the FrontNet 1 and the same from the FrontNet 2. In turn, each iSCSI target is assigned a static IP address from the FrontNet 1 and a static IP address from the FrontNet 2. In case one of the frontnets fails, the iSCSI targets will still be accessible via the other one.

To enable multipath I/O for a Virtuozzo Storage iSCSI target, assign to it multiple IP addresses from different networks using the ``-a`` option. For example, for a Node connected to two networks, 192.168.10.0/24 and 192.168.20.0/24, run the following command:

::

    # vstorage-iscsi create -n ps1 -a 192.168.10.101 -a 192.168.20.101

.. _Managing CHAP Accounts for Virtuozzo Storage iSCSI Targets:

Managing CHAP Accounts for Virtuozzo Storage iSCSI Targets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Virtuozzo Storage allows you to restrict access to iSCSI targets by means of CHAP authentication.

To make use of CHAP authentication, you need to:

1. Create a CHAP account.

2. Create an iSCSI target bound to this CHAP account.

These actions are described in detail in the following subsections.

.. _Creating CHAP Accounts for Virtuozzo Storage iSCSI Targets:

Creating CHAP Accounts for Virtuozzo Storage iSCSI Targets
**********************************************************

To create a CHAP account, use the ``vstorage-iscsi account-create`` command. For example, to create the CHAP account ``user1``:

::

    # vstorage-iscsi account-create -u user1
    Enter password:
    Verify password:

.. note::The password should be 12 to 16 characters long for Windows clients to be able to establish connection.

.. _Creating Virtuozzo Storage iSCSI Targets Bound to CHAP Accounts:

Creating Virtuozzo Storage iSCSI Targets Bound to CHAP Accounts
***************************************************************

To create a Virtuozzo Storage iSCSI target bound to a CHAP account, use the ``vstorage-iscsi create`` command with the additional ``-u`` option. For example, create a target bound to the CHAP account ``user1``:

::

    # vstorage-iscsi create -n test1 -a 192.168.10.100 -u user1
    IQN: iqn.2014-04.com.vstorage:test1

.. _Changing the CHAP Account Password:

Changing the CHAP Account Password
**********************************

To change the password of a CHAP account, use the ``vstorage-iscsi account-set`` command. For example, to change the password of the CHAP account ``user1``:

::

    # vstorage-iscsi account-set -u user1
    Enter password:
    Verify password:

.. note::The password should be 12 to 16 characters long for Windows clients to be able to establish connection.

The new password will become active after target reboot.

.. _Listing CHAP Accounts and Virtuozzo Storage iSCSI Targets Assigned to Them:

Listing CHAP Accounts and Virtuozzo Storage iSCSI Targets Assigned to Them
**************************************************************************

To list existing CHAP accounts, use the ``vstorage-iscsi account-list`` command. For example:

::

    # vstorage-iscsi account-list
    user1

To list Virtuozzo Storage iSCSI targets assigned to a specific CHAP account, use the ``vstorage-iscsi account-list`` command with the ``-u`` option. For example, to list iSCSI targets assigned to the CHAP account ``user1``:

::

    # vstorage-iscsi account-list -u user1
    iqn.2014-04.com.vstorage:test1

.. _Managing LUN Snapshots:

Managing LUN Snapshots
~~~~~~~~~~~~~~~~~~~~~~

As with virtual machines, you can create and manage snapshots of LUNs. At that, to create a snapshot of the entire target, you will need to create snapshots of each LUN within it.

.. _Creating LUN Snapshots:

Creating LUN Snapshots
**********************

To create a snapshot of a LUN in an iSCSI target, use the ``vstorage-iscsi snapshot-create`` command. For example, for LUN 1 on target ``iqn.2014-04.com.vstorage:test1``:

::

    # vstorage-iscsi snapshot-create -t iqn.2014-04.com.vstorage:test1 -l 1
    Snapshot a1f54314-bc06-40c6-a587-965feb9d85bb successfully created.

.. note:: To generate a UUID manually, use ``uuidgen``.

.. _Listing LUN Snapshots:

Listing LUN Snapshots
*********************

To list snapshots for the specified LUN, use the ``vstorage-iscsi snapshot-list`` command. For example, for LUN 1 on ``target iqn.2014-04.com.vstorage:test1``:

::

    # vstorage-iscsi snapshot-list -t iqn.2014-04.com.vstorage:stor4 -l 1
    CREATED             C UUID                                 PARENT_UUID                        
    2014-04-11 13:16:51   a1f54314-bc06-40c6-a587-{...} 00000000-0000-0000-{...}
    2014-04-11 13:16:57 * 9c98b442-7482-4fd0-9c45-{...} a1f54314-bc06-40c6-{...}

In the output above, the asterisk in the column ``C`` indicates the current snapshot, while the column ``PARENT_UUID`` shows snapshot dependency or history.

.. _Switching Between LUN Snapshots:

Switching Between LUN Snapshots
*******************************

To switch to the specified LUN snapshot, use the ``vstorage-iscsi snapshot-switch`` command. For example:

::

    # vstorage-iscsi snapshot-switch -u a1f54314-bc06-40c6-a587-965feb9d85bb

After you switch to a snapshot, the current LUN image will be removed.

.. note:: You can only switch between snapshots, if the LUN is offline.

.. _Viewing LUN Snapshot Information:

Viewing LUN Snapshot Information
********************************

To view information about the specified snapshot, use the ``vstorage-iscsi snapshot-info`` command. For example:

::

    # vstorage-iscsi snapshot-info -u 9c98b442-7482-4fd0-9c45-9259374ca84e
    Target: iqn.2014-04.com.vstorage:stor4
    LUN: 1
    Created: 2014-04-11 13:16:57
    Parent: 00000000-0000-0000-0000-000000000000}
    {a1f54314-bc06-40c6-a587-965feb9d85bb}
    {9c98b442-7482-4fd0-9c45-9259374ca84e
    Description: None

.. _Deleting LUN Snapshots:

Deleting LUN Snapshots
**********************

To delete the specifed LUN snapshot, use the ``vstorage-iscsi snapshot-delete`` command. For example:

::

    # vstorage-iscsi snapshot-delete -u a1f54314-bc06-40c6-a587-965feb9d85bb

If the snapshot has no any children, it will be deleted. If the snapshot has a single child, it will be merged to that child.

.. note::

   1. You can only delete offline snapshots.

   2. Deleting a snapshot that has multiple children is currently not supported.
