Less known Solaris Features: iSCSI - Part 2: Basic iSCSI

At first I will show you, how to do a really simple iSCSI configuration. This is without any authentication. Thus everybody can connect to the iSCSI targets on the system. But this is sufficient for a test. And it´s this is better for having a quick success. ;)

Environment

For this example, i will use my both demo VMs again:

10.211.55.200   theoden<br />
10.211.55.201   gandalf

Both systems runs with Solaris Express Build 84 for x86, but you can to the same with Solaris Update 4 for SPARC and x86 as well. In our example, theoden is the server with the iSCSI target. gandalf is the server, which wants to use the the LUN via iSCSI on theoden, thus gandalf is the server with the initiator.

Prerequisites

At first, we login to theoden and assume root privileges. Okay, to test iSCSI we need some storage volumes to play around. There is a nice way to create a playground with ZFS. You can use files as devices. But at first we have to create this files

# mkdir /zfstest<br />
# cd /zfstest<br />
#  mkfile 128m test1<br />
#  mkfile 128m test2<br />
#  mkfile 128m test3<br />
#  mkfile 128m test4

Okay, now we stripe those four files in a zpool:

# zpool create testpool /zfstest/test1 /zfstest/test2 /zfstest/test3 /zfstest/test4

Now we make a short check for the zpool

# zpool list<br />
NAME       SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT<br />
testpool   492M    97K   492M     0%  ONLINE  -

Configuring the iSCSI Target

We stay at server theoden. Okay, now we have to configure an iSCSI target. We create an emulated volume within the zfspool:

# zfs create -V 200m testpool/zfsvolume<br />
# zfs list<br />
NAME                 USED  AVAIL  REFER  MOUNTPOINT<br />
testpool             200M   260M    18K  /testpool<br />
testpool/zfsvolume   200M   460M    16K  -

The emulated volume has the size of 200M.Okay, it´s really easy to enable the iSCSI target. At first we have to enable the iSCSI Target service:

# svcadm enable iscsitgt

Now we share the volume via iSCSI

# zfs set shareiscsi=on testpool/zfsvolume

That´s all on the target

Configuring the iSCSI initiator

Okay, now we have configure the initiator. We have to login on gandalf and assume root privileges as well. At first we have to activate the initiator via SMF:

# svcadm enable iscsi_initiator

After this we configure the initiator and tell the initiator to discover devices on our iSCSI target.

# iscsiadm modify initiator-node -A gandalf<br />
# iscsiadm add discovery-address 10.211.55.200<br />
# iscsiadm modify discovery -t enable

Using the iSCSI device

Okay, now tell Solaris to scan for iSCSI devices.

# devfsadm -c iscsi

The -c iscsi limits the scan to iSCSI devices. With the format command we look for the available disks in the system:

<br />
# format<br />
Searching for disks...done
AVAILABLE DISK SELECTIONS:<br />
       0. c0d0 <DEFAULT cyl 4076 alt 2 hd 255 sec 63><br />
          /pci@0,0/pci-ide@1f,1/ide@0/cmdk@0,0<br />
       1. c1d0 <DEFAULT cyl 4077 alt 2 hd 255 sec 63><br />
          /pci@0,0/pci-ide@1f,1/ide@1/cmdk@0,0<br />
       2. c2t0100001C42E9F21A00002A0047E39E34d0 <DEFAULT cyl 198 alt 2 hd 64 sec 32><br />
          /scsi_vhci/disk@g0100001c42e9f21a00002a0047e39e34<br />
Specify disk (enter its number): ^C

Okay, there is new device with a really long name. We can use this device for a zfs pool:

# zpool create zfsviaiscsi c2t0100001C42E9F21A00002A0047E39E34d0<br />
# zpool list<br />
NAME          SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT<br />
zfsviaiscsi   187M   480K   187M     0%  ONLINE  -<br />
#

As you see, we have created a zfs filesystem via iSCSI on an emulated volume on a zpool on a remote system.