Setting up iSCSI targets on Solaris
by Mark on Feb.03, 2009, under solaris
This example is using snv66 for the target, and Solaris 10u3 for the initiator, as iSCSI target isn’t in Solaris 10u3 (11/06), but is in from u4 (08/07). This should work fine on Solaris 10 u4 and beyond.
Many thanks to Ryan Matteson’s excellent notes.
** On the target
* create zfs ‘volume’ which will be the backing store (our exported disk)
zfs create -V 50g tank/iscsivol000
* create iscsi ‘base’ directory (config store)
iscsitadm modify admin -d /etc/iscsitgt
* create iscsi target
iscsitadm create target -b /dev/zvol/dsk/tank/iscsivol000 target-label
* list the targets so far if you want…
iscsitadm list target -v
* If there are more than one interface, and you want to bind to a particular one, add a tpgt…
iscsitadm create tpgt 1
iscsitadm modify tpgt -i 10.101.90.136 1
iscsitadm modify target -p 1 target-label
* checkout the *client* host’s initiator…
iscsiadm list initiator-node
root@host ~ # iscsiadm list initiator-node
Initiator node name: iqn.1986-03.com.sun:01:ac7812f012ff.45ed6c53
* create an alias for that initiator back on our target (server)…
iscsitadm create initiator -n iqn.1986-03.com.sun:01:ac7812f012ff.45ed6c53 suitable-alias
* add an acl to the target…
iscsitadm modify target -l suitable-alias target-label
** on the initiator:
* list discovery modes…
root@host ~ # iscsiadm list discovery
Discovery:
Static: disabled
Send Targets: disabled
iSNS: disabled
* sendtargets discovery enable
iscsiadm modify discovery –sendtargets enable
* and list…
root@host ~ # iscsiadm list discovery
Discovery:
Static: disabled
Send Targets: enable
iSNS: disabled
* add a discovery address (our target server)
iscsiadm add discovery-address IP.ADD.RES.SS
NOTE: must be IP address
* show what’s exported
iscsiadm list target
[snip]
LUN: 0
Vendor: SUN
Product: SOLARIS
OS Device Name: /dev/rdsk/c3t0100001B2BC4078001002A0046AEE439d0s2
* enable the device…
devfsadm -Cv -i iscsi
* see what’s there…
root@host ~ # echo | format
Searching for disks…done
AVAILABLE DISK SELECTIONS:
0. c2t0d0
/pci@7b,0/pci1022,7458@11/pci1000,3060@2/sd@0,0
1. c2t1d0
/pci@7b,0/pci1022,7458@11/pci1000,3060@2/sd@1,0
2. c3t0100001B2BC4078001002A0046AEE439d0
/scsi_vhci/disk@g0100001a4ba4078000002a0046b6e439
Specify disk (enter its number): Specify disk (enter its number):
* manage with zfs
root@host ~ # zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
tank 62G 17.2G 44.8G 27% ONLINE -
root@host ~ # zpool create iscsitank c3t0100001B2BC4078001002A0046AEE439d0
root@host ~ # zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
iscsitank 49.8G 53.5K 49.7G 0% ONLINE -
tank 62G 17.2G 44.8G 27% ONLINE -
* do some stuff
root@host ~ # zfs create iscsitank/test
root@host ~ # zfs set mountpoint=none iscsitank
root@host ~ # zfs set mountpoint=/test iscsitank/test
root@host ~ # zfs list | grep iscsi
iscsitank 120K 49.0G 25.5K none
iscsitank/test 24.5K 49.0G 24.5K /test
* Removing a target
On the client, unmount/zpool destroy the drive
root@host ~ # iscsitadm list target -v
root@host ~ # iscsitadm delete target -u 0 target-tgt0
where -u is LUN ID.
March 4th, 2009 on 10:54 pm
Hi…this is a handy website. Just a note–I noticed that “-sendtargets” should be “–sendtargets”.
Say, I tried these instructions and when it came time to list targets on the client (i.e. “iscsiadm list target”), there was no output (and no error either, just the prompt). Any idea? (There was a generic message in /var/adm/messages, that there was an iscsi failure. Unfortunately, that machine is down and I cannot access that text.)
Thanks for any leads.
Janice
March 4th, 2009 on 11:52 pm
Hi Janice,
Thanks for dropping by. I think it’s a font thing with the –sendtargets switch, as the post source does actually say ‘minus minus’ and not just ‘dash’. Sorry about that; maybe time to review the CSS eh?
Sorry, I can’t help with your problem without a bit more information. Naturally this all worked just fine for me! If you do have some more debug information feel free to post it back and I’ll see if I can suggest an answer.
September 1st, 2009 on 5:42 pm
Pretty useful information here Mark.
I too had a problem where “iscsiadm list target” returned nothing. What I found that I had to do was:
1 – ensure that the iscsi_initiator service was enabled:
# svcs svc:/network/iscsi_initiator:default
# svcadm enable svc:/network/iscsi_initiator:default
2 – Create the iscsi device links:
# devfsadm -Cv -i iscsi
Then I was able to see the iscsi target devices.
September 6th, 2009 on 7:56 pm
Thanks for posting the tip Ron, I’m sure others will appreciated that.
Cheers