[root@cloud0 ~]# fdisk /dev/sdb
Command (m for help): p
Disk /dev/sdb: 240.0 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-29185, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-29185, default 29185):
Using default value 29185
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 240.0 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 29185 234428481 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
This gives me a new partition - /dev/sdb1. Now lets create the Logical Volumes to be shared out via iSCSI.
[root@cloud0 ~]# pvcreate /dev/sdb1
[root@cloud0 ~]# vgcreate VG_iSCSI /dev/sdb1
[root@cloud0 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VG_XenStorage-19756537-a3bc-5c1f-edfc-01bc47ddf5d8 1 8 0 wz--n- 923.50G 354.21G
VG_iSCSI 1 0 0 wz--n- 223.57G 223.57G
4. Creating a Logical Volume
[root@cloud0 ~]#lvcreate -L 223G –name iSCSI_disk1 VG_iSCSI
[root@cloud0 ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
MGT VG_XenStorage-19756537-a3bc-5c1f-edfc-01bc47ddf5d8 -wi-a- 4.00M
iSCSI_disk1 VG_iSCSI -wi-a- 223.00G
5. List active targets
[root@cloud0 ~]# tgtadm --lld iscsi --mode target --op show
6. Create a new target device
[root@cloud0 ~]#tgtadm --lld iscsi --mode target --op new --tid=1 --targetname iqn.2011-09.edu.edcc:disk1
7. Add a logical unit (LUN)
[root@cloud0 ~]# tgtadm --lld iscsi --mode logicalunit --op new --tid=1 --lun=1 --backing-store=/dev/VG_iSCSI/iSCSI_disk1
To add more units repeat step 4 by incrementing the LV --name (iSCSI-disk1) and step 6 by changing the --lun number and --backing-store parameter to add more LUNs.
For example:
[root@cloud0 ~]# lvcreate -L 10G --name iSCSI-disk2 VG_iSCSI
[root@cloud0 ~]# tgtadm --lld iscsi --mode logicalunit --op new --tid=1 --lun=2 --backing-store=/dev/VG_iSCSI/iSCSI_disk2
In case you mess it up and want to delete the LUN and Target
[root@cloud0 ~]# tgtadm --lld iscsi --mode logicalunit --op delete --tid=1 --lun=1
[root@cloud0 ~]# tgtadm --lld iscsi --mode target --op delete –tid=1
8. Setting up Access Control
We're going to allow all iSCSI initators to connect. This is not very secure so if you want to limit this you'll want to do it here. You can limit by IP address range or network. You can also set up CHAP authentication.
[root@cloud0 ~]# tgtadm --lld iscsi --mode target --op bind --tid=1 -I ALL
9. Creating the Software iSCSI Storage Repository
Log into your Pool Master using ssh and run xsconsole. Choose Disks and Storage Repositories then Create New Storage Repository. When prompted type in the root users name and password then select Software iSCSI. You can name it anything you want and provide a description too. The only field you really need is the Hostname or iSCSI Target field. Put in the IP or Hostname of your iSCSI Target and hit enter to let it probe the iSCSI target. It will show you a list of LUNs, choose the one you want and press F-8. This will create the storage repository. It may also make it default which you may not want.
10. Change the default storage repository
In my case I wanted to use the new iSCSI SAN as additional drives and not my default SR. When you use xsconsole to create the Storage Repository it also makes it default. To make a different SR default follow these instructions. If you want the iSCSI SR to be default skip this step.
Get the pool UUID, get the SR UUID then set it default.
[root@cloud1 ~]# xe pool-list
uuid ( RO) : a8cff715-6ff7-a01f-b7a3-7ad3b158df71
name-label ( RW):
name-description ( RW):
master ( RO): 47c0e22c-eac9-444d-a4b1-d958f0ab60cf
default-SR ( RW): 36bf480a-5df9-4453-50f0-2bac4a86cb42
[root@cloud1 ~]# xe sr-list
uuid ( RO) : 36bf480a-5df9-4453-50f0-2bac4a86cb42
name-label ( RW): Local storage
name-description ( RW):
host ( RO): cloud1.acs.edcc.edu
type ( RO): lvm
content-type ( RO): user
[root@cloud1 ~]# xe pool-param-set default-SR=36bf480a-5df9-4453-50f0-2bac4a86cb42 uuid=a8cff715-6ff7-a01f-b7a3-7ad3b158df71
Now you a software iSCSI Target on XCP 1.1, a disk that's shared out via iSCSI and a Software Repository that uses it.