2.4. Managing Volumes

This section describes how to create and manage volumes to be exported via iSCSI.

2.4.1. Creating Volumes

To create a volume, use the vstorage-target vol-create command. For example:

# vstorage-target vol-create -name vol1 -size 1G \
-vstorage-attr "replicas=3:2 failure-domain=host tier=0"
{
  "Id": "3277153b-5296-49c5-9b66-4c200ddb343d"
}

This command creates a 1 GB volume named vol1 on storage tier 0 with 3:2 replication and host as failure domain.

2.4.2. Listing and Printing Details of Volumes

To list volumes, use the vstorage-target vol-list command. For example:

# vstorage-target vol-list
[
  "3277153b-5296-49c5-9b66-4c200ddb343d",
  "a12110d5-cbbc-498a-acdd-a8567286f927",
  "d5cc3c13-cfb4-4890-a20d-fb80e2a56278"
]

Add -all to print details of all volumes. To print details of a specific volume, run vstorage-target vol-stat -id <vol_ID>.

2.4.3. Attaching Volumes to Target Groups

To attach a volume to a target group, use the vstorage-target tg-attach command. A volume cannot be attached to multiple target groups at the same time. For example:

# vstorage-target tg-attach -id 3d8364f5-b830-4211-85af-3a19d30ebac4 \
-volume 3277153b-5296-49c5-9b66-4c200ddb343d -lun 0

This command attaches the volume with the ID 3277153b-5296-49c5-9b66-4c200ddb343d to a target group with the ID 3d8364f5-b830-4211-85af-3a19d30ebac4 as LUN 0. LUN ID numbering must start with 0.

2.4.4. Viewing and Setting Volume Parameters

To view and set volume parameters, e.g. redundancy mode, failure domain, or tier, use the commands vstorage-target vol-attr get and vstorage-target vol-attr set, respectively. For example:

# vstorage-target vol-attr get -id d5cc3c13-cfb4-4890-a20d-fb80e2a56278
{
  "chunk-size": "268435456",
  "client-ssd-cache": "1",
  "failure-domain": "host",
  "replicas": "3:2",
  "tier": "0"
}
# vstorage-target vol-attr set -id d5cc3c13-cfb4-4890-a20d-fb80e2a56278 \
-vstorage-attr "replicas=2:1 tier=1"

2.4.5. Increasing Volume Size

To increase the size of a volume, use the vstorage-target vol-grow command. For example:

# vstorage-target vol-grow -id d5cc3c13-cfb4-4890-a20d-fb80e2a56278 -size 2G

2.4.6. Setting Volume Limits

To set read/write limits for a volume, use the vstorage-target vol-limits command. For example:

# vstorage-target vol-limits -id d5cc3c13-cfb4-4890-a20d-fb80e2a56278 -read-bps 10485760 \
-write-bps 10485760

This command sets read/write speed for the volume with the ID d5cc3c13-cfb4-4890-a20d-fb80e2a56278 to 10485760 bytes per second.

2.4.7. Detaching Volumes from Target Groups

To detach a volume from a target group, use the vstorage-target tg-detach command. LUN 0 must be detached last. For example:

# vstorage-target tg-detach -id 3d8364f5-b830-4211-85af-3a19d30ebac4 \
-volume d5cc3c13-cfb4-4890-a20d-fb80e2a56278

This command detaches the volume with the ID d5cc3c13-cfb4-4890-a20d-fb80e2a56278 from the target group with the ID 3d8364f5-b830-4211-85af-3a19d30ebac4.

2.4.8. Deleting Volumes

To delete a volume, use the vstorage-target vol-delete command. You cannot delete volumes attached to target groups. For example:

# vstorage-target vol-delete -id d5cc3c13-cfb4-4890-a20d-fb80e2a56278

This command deletes the volume with the ID d5cc3c13-cfb4-4890-a20d-fb80e2a56278.