Create a storage repository
You can create local and remote storage repositories by using the xe CLI. Here are two basic steps to create a storage repository for use on a host by using the CLI:
-
Determine values for any required parameters by probing the SR type with the command
xe sr-probe. -
Create the SR with the command
xe sr-create.This command creates an SR on the storage substrate (potentially destroying any existing data). It also creates the SR API object and a corresponding PBD record, enabling VMs to use the storage. On successful creation of the SR, the PBD is automatically plugged. If the flag
shared=trueis set, a PBD record is created and plugged for every XenServer host in the resource pool.
These steps differ in detail depending on the type of SR being created. In all examples, the sr-create command returns the UUID of the created SR if successful.
Alternatively, you can use the New Storage Repository wizard in XenCenter to create remote storage repositories (SRs). The wizard guides you through the configuration steps. For more information, see the XenCenter documentation.
For examples of how to create an SR, see the article for the storage type you use:
ISO libraries:
Flie-based storage:
Block-based storage:
- Software iSCSI storage
- Hardware HBA storage
- Software FCoE storage (deprecated)
- Thin-provisioned shared GFS2 block storage
All XenServer SR types support VDI resize, fast cloning, and snapshot. SRs based on the LVM SR type (local, iSCSI, or HBA) provide thin provisioning for snapshot and hidden parent nodes, but not for other disks, such as MCS per-VM delta disks. The other SR types (EXT3/EXT4, NFS, GFS2, and XFS) support full thin provisioning, including for virtual disks that are active.
Warnings:
When VHD VDIs are not attached to a VM, for example for a VDI snapshot, they are stored as thinly provisioned by default. If you attempt to reattach the VDI, ensure that there is sufficient disk-space available for the VDI to become thickly provisioned. VDI clones are thickly provisioned.
XenServer® does not support snapshots at the external SAN-level of a LUN for any SR type.
Do not attempt to create an SR where the LUN ID of the destination LUN is greater than 255. Ensure that your target exposes the LUN with a LUN ID that is less than or equal to 255 before using this LUN to create an SR.
If you use thin provisioning on a file-based SR, ensure that you monitor the free space on your SR. If the SR usage grows to 100%, further writes from VMs fail. These failed writes can cause the VM to freeze or crash, and can lead to data corruption.
Probe an SR
The sr-probe command can be used in the following ways:
- To identify unknown parameters for use in creating an SR
- To return a list of existing SRs
In both cases sr-probe works by specifying an SR type and one or more device-config parameters for that SR type. If an incomplete set of parameters is supplied, the sr-probe command returns an error message indicating parameters are missing and the possible options for the missing parameters. When a complete set of parameters is supplied, a list of existing SRs is returned. All sr-probe output is returned as XML.
For example, a known iSCSI target can be probed by specifying its name or IP address. The set of IQNs available on the target is returned:
xe sr-probe type=lvmoiscsi device-config:target=192.168.1.10
Error code: SR_BACKEND_FAILURE_96
Error parameters: , The request is missing or has an incorrect target IQN parameter, \
<?xml version="1.0" ?>
<iscsi-target-iqns>
<TGT>
<Index>
0
</Index>
<IPAddress>
192.168.1.10
</IPAddress>
<TargetIQN>
iqn.192.168.1.10:filer1
</TargetIQN>
</TGT>
</iscsi-target-iqns>
<!--NeedCopy-->
Probing the same target again and specifying both the name/IP address and desired IQN returns the set of SCSIids (LUNs) available on the target/IQN.
xe sr-probe type=lvmoiscsi device-config:target=192.168.1.10 \
device-config:targetIQN=iqn.192.168.1.10:filer1
Error code: SR_BACKEND_FAILURE_107
Error parameters: , The SCSIid parameter is missing or incorrect, \
<?xml version="1.0" ?>
<iscsi-target>
<LUN>
<vendor>
IET
</vendor>
<LUNid>
0
</LUNid>
<size>
42949672960
</size>
<SCSIid>
149455400000000000000000002000000b70200000f000000
</SCSIid>
</LUN>
</iscsi-target>
<!--NeedCopy-->
Probing the same target and supplying all three parameters returns a list of SRs that exist on the LUN, if any.
xe sr-probe type=lvmoiscsi device-config:target=192.168.1.10 \
device-config:targetIQN=192.168.1.10:filer1 \
device-config:SCSIid=149455400000000000000000002000000b70200000f000000
<?xml version="1.0" ?>
<SRlist>
<SR>
<UUID>
3f6e1ebd-8687-0315-f9d3-b02ab3adc4a6
</UUID>
<Devlist>
/dev/disk/by-id/scsi-149455400000000000000000002000000b70200000f000000
</Devlist>
</SR>
</SRlist>
<!--NeedCopy-->
The following parameters can be probed for each SR type:
| SR type | The device-config parameters, in order of dependency |
Can be probed? | Required for sr-create? |
|---|---|---|---|
lvmoiscsi |
target |
No | Yes |
chapuser |
No | No | |
chappassword |
No | No | |
targetIQN |
Yes | Yes | |
SCSIid |
Yes | Yes | |
lvmohba |
SCSIid |
Yes | Yes |
lvmofcoe |
SCSIid |
Yes | Yes |
nfs |
server |
No | Yes |
serverpath |
Yes | Yes | |
smb |
server |
No | Yes |
username |
No | No | |
password |
No | No | |
lvm |
device |
No | Yes |
ext |
device |
No | Yes |
For information about probing a GFS2 SR, see Create a GFS2 SR.